From b5f05118c770d7bf7bfc9633e6d112e25566e576 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 10 Oct 2014 12:02:46 -0300 Subject: [PATCH] update models tests to new API --- js/models/Wallet.js | 15 ++++++++------- test/Wallet.js | 19 +++++++------------ test/models/Identity.js | 5 +++-- views/includes/sidebar.html | 4 ++++ 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/js/models/Wallet.js b/js/models/Wallet.js index c082db16c..8b206ccea 100644 --- a/js/models/Wallet.js +++ b/js/models/Wallet.js @@ -5,6 +5,7 @@ var _ = require('underscore'); var preconditions = require('preconditions').singleton(); var inherits = require('inherits'); var events = require('events'); +var async = require('async'); var bitcore = require('bitcore'); var bignum = bitcore.Bignum; @@ -865,22 +866,22 @@ Wallet.prototype._lockIncomming = function() { Wallet.prototype._setBlockchainListeners = function() { var self = this; - this.blockchain.removeAllListeners(); + self.blockchain.removeAllListeners(); - this.blockchain.on('reconnect', function(attempts) { - log.debug('Wallet:' + this.id +'blockchain reconnect event'); + self.blockchain.on('reconnect', function(attempts) { + log.debug('Wallet:' + self.id +'blockchain reconnect event'); self.emit('insightReconnected'); // Subscription should persist? TODO //self.subscribeToAddresses(); }); - this.blockchain.on('disconnect', function() { - log.debug('Wallet:' + this.id +'blockchain disconnect event'); + self.blockchain.on('disconnect', function() { + log.debug('Wallet:' + self.id +'blockchain disconnect event'); self.emit('insightError'); }); - this.blockchain.on('tx', function(tx) { - log.debug('Wallet:' + this.id +'blockchain tx event'); + self.blockchain.on('tx', function(tx) { + log.debug('Wallet:' + self.id +'blockchain tx event'); var addresses = self.getAddressesInfo(); var addr = _.findWhere(addresses, { addressStr: tx.address diff --git a/test/Wallet.js b/test/Wallet.js index f344969b4..5756a5fe8 100644 --- a/test/Wallet.js +++ b/test/Wallet.js @@ -419,20 +419,15 @@ describe('Wallet model', function() { it('decodeSecret check', function() { - (function() { - Wallet.decodeSecret('4fp61K187CsYmjoRQC5iAdC5eGmbCRsAAXfwEwetSQgHvZs27eWKaLaNHRoKM'); - }).should.not. - throw(); + var s = Wallet.decodeSecret('4fp61K187CsYmjoRQC5iAdC5eGmbCRsAAXfwEwetSQgHvZs27eWKaLaNHRoKM'); + should.exist(s); - (function() { - Wallet.decodeSecret('4fp61K187CsYmjoRQC5iAdC5eGmbCRsAAXfwEwetSQgHvZs27eWKaLaNHRoK'); - }).should. - throw(); + s= Wallet.decodeSecret('4fp61K187CsYmjoRQC5iAdC5eGmbCRsAAXfwEwetSQgHvZs27eWKaLaNHRoK'); + s.should.equal(false); - (function() { - Wallet.decodeSecret('12345'); - }).should. - throw(); + + s= Wallet.decodeSecret('123456'); + s.should.equal(false); }); diff --git a/test/models/Identity.js b/test/models/Identity.js index 3544e8899..40c22e813 100644 --- a/test/models/Identity.js +++ b/test/models/Identity.js @@ -42,6 +42,7 @@ describe('Identity model', function() { wallet = sinon.stub(); wallet.store = sinon.stub().yields(null); + wallet.netStart = sinon.stub(); wallet.getId = sinon.stub().returns('wid:123'); Identity._newWallet = sinon.stub().returns(wallet); @@ -129,7 +130,7 @@ describe('Identity model', function() { storage.getFirst = sinon.stub().yields('wallet1234'); profile.listWallets = sinon.stub().returns([{id:'walletid'}]); Identity._openProfile = sinon.stub().callsArgWith(3, null, profile); - Identity._walletRead = sinon.stub().callsArgWith(5, null, wallet); + Identity._walletRead = sinon.stub().callsArgWith(2, null, wallet); }); it('should call ._openProfile', function(done) { @@ -234,7 +235,7 @@ describe('Identity model', function() { var wallet = sinon.stub(); wallet.store = sinon.stub().yields(null); - Identity._walletRead = sinon.stub().callsArgWith(5, null, wallet); + Identity._walletRead = sinon.stub().callsArgWith(2, null, wallet); }); it('should return wallet and call .store, .setLastOpenedTs & .migrateWallet', function(done) { diff --git a/views/includes/sidebar.html b/views/includes/sidebar.html index d10c0cf10..5507316b5 100644 --- a/views/includes/sidebar.html +++ b/views/includes/sidebar.html @@ -64,6 +64,10 @@ + +
  • {{'Close'|translate}}