fix some wallet tests

This commit is contained in:
Matias Alejo Garcia 2014-09-09 22:06:19 -03:00
commit d838a29d02
3 changed files with 19 additions and 14 deletions

View file

@ -121,7 +121,6 @@ module.exports = function(grunt) {
'js/controllers/*.js',
'js/translations.js',
'js/mobile.js', // PLACEHOLDER: CORDOVA SRIPT
'js/log.js',
'js/init.js'
],
dest: 'js/copayMain.js'

View file

@ -329,12 +329,11 @@ Wallet.prototype._onTxProposal = function(senderId, data) {
var keyMap = this._getKeyMap(m.txp);
m.newCopayer = m.txp.setCopayers(senderId, keyMap);
} catch (e) {
log.error('Corrupt TX proposal received from:', senderId, e);
return;
log.error('Corrupt TX proposal received from:', senderId, e.toString());
m=null;
}
if (m) {
if (m.hasChanged) {
m.txp.setSeen(this.getMyCopayerId());
this.sendSeen(m.ntxid);

View file

@ -1400,31 +1400,38 @@ describe('Wallet model', function() {
var txp = {
'txProposal': txp
};
var merge = sinon.stub(w.txProposals, 'merge', function() {
if (response == 0) throw new Error();
var s1 = sinon.stub(w, '_getKeyMap', function() {
return {1:2};
});
var s2 = sinon.stub(w.txProposals, 'merge', function() {
if (response == 0)
throw new Error('test error');
return {
newCopayer: ['juan'],
ntxid: 1,
txp: {
setCopayers: function() {return ['oeoe']; } ,
},
new: response == 1
};
});
w._onTxProposal('senderID', txp);
spy.callCount.should.equal(1);
merge.restore();
s1.restore();
s2.restore();
};
it('should handle corrupt', function(done) {
var result = 'corrupt';
testValidate(0, result, done);
testValidate(0, 'corrupt', done);
});
it('should handle new', function(done) {
var result = 'new';
testValidate(1, result, done);
testValidate(1, 'new', done);
});
it('should handle signed', function(done) {
var result = 'signed';
testValidate(2, result, done);
testValidate(2, 'signed', done);
});
});