fix some wallet tests
This commit is contained in:
parent
24e5e28e15
commit
d838a29d02
3 changed files with 19 additions and 14 deletions
|
|
@ -121,7 +121,6 @@ module.exports = function(grunt) {
|
||||||
'js/controllers/*.js',
|
'js/controllers/*.js',
|
||||||
'js/translations.js',
|
'js/translations.js',
|
||||||
'js/mobile.js', // PLACEHOLDER: CORDOVA SRIPT
|
'js/mobile.js', // PLACEHOLDER: CORDOVA SRIPT
|
||||||
'js/log.js',
|
|
||||||
'js/init.js'
|
'js/init.js'
|
||||||
],
|
],
|
||||||
dest: 'js/copayMain.js'
|
dest: 'js/copayMain.js'
|
||||||
|
|
|
||||||
|
|
@ -329,12 +329,11 @@ Wallet.prototype._onTxProposal = function(senderId, data) {
|
||||||
var keyMap = this._getKeyMap(m.txp);
|
var keyMap = this._getKeyMap(m.txp);
|
||||||
m.newCopayer = m.txp.setCopayers(senderId, keyMap);
|
m.newCopayer = m.txp.setCopayers(senderId, keyMap);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error('Corrupt TX proposal received from:', senderId, e);
|
log.error('Corrupt TX proposal received from:', senderId, e.toString());
|
||||||
return;
|
m=null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m) {
|
if (m) {
|
||||||
|
|
||||||
if (m.hasChanged) {
|
if (m.hasChanged) {
|
||||||
m.txp.setSeen(this.getMyCopayerId());
|
m.txp.setSeen(this.getMyCopayerId());
|
||||||
this.sendSeen(m.ntxid);
|
this.sendSeen(m.ntxid);
|
||||||
|
|
|
||||||
|
|
@ -1400,31 +1400,38 @@ describe('Wallet model', function() {
|
||||||
var txp = {
|
var txp = {
|
||||||
'txProposal': 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 {
|
return {
|
||||||
newCopayer: ['juan'],
|
|
||||||
ntxid: 1,
|
ntxid: 1,
|
||||||
|
txp: {
|
||||||
|
setCopayers: function() {return ['oeoe']; } ,
|
||||||
|
},
|
||||||
new: response == 1
|
new: response == 1
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
w._onTxProposal('senderID', txp);
|
w._onTxProposal('senderID', txp);
|
||||||
spy.callCount.should.equal(1);
|
spy.callCount.should.equal(1);
|
||||||
merge.restore();
|
s1.restore();
|
||||||
|
s2.restore();
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should handle corrupt', function(done) {
|
it('should handle corrupt', function(done) {
|
||||||
var result = 'corrupt';
|
testValidate(0, 'corrupt', done);
|
||||||
testValidate(0, result, done);
|
|
||||||
});
|
});
|
||||||
it('should handle new', function(done) {
|
it('should handle new', function(done) {
|
||||||
var result = 'new';
|
testValidate(1, 'new', done);
|
||||||
testValidate(1, result, done);
|
|
||||||
});
|
});
|
||||||
it('should handle signed', function(done) {
|
it('should handle signed', function(done) {
|
||||||
var result = 'signed';
|
testValidate(2, 'signed', done);
|
||||||
testValidate(2, result, done);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue