From d838a29d0246f1bfbe8de4a84c756649b9411499 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Tue, 9 Sep 2014 22:06:19 -0300 Subject: [PATCH] fix some wallet tests --- Gruntfile.js | 1 - js/models/core/Wallet.js | 5 ++--- test/test.Wallet.js | 27 +++++++++++++++++---------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 57bd9a50d..4b1216fb4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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' diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 4e9cc6f79..47fdbd0f3 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -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); diff --git a/test/test.Wallet.js b/test/test.Wallet.js index 7a8dac56f..2ed4298a2 100644 --- a/test/test.Wallet.js +++ b/test/test.Wallet.js @@ -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); }); });