update models tests to new API
This commit is contained in:
parent
006bf4c1fa
commit
b5f05118c7
4 changed files with 22 additions and 21 deletions
|
|
@ -5,6 +5,7 @@ var _ = require('underscore');
|
||||||
var preconditions = require('preconditions').singleton();
|
var preconditions = require('preconditions').singleton();
|
||||||
var inherits = require('inherits');
|
var inherits = require('inherits');
|
||||||
var events = require('events');
|
var events = require('events');
|
||||||
|
var async = require('async');
|
||||||
|
|
||||||
var bitcore = require('bitcore');
|
var bitcore = require('bitcore');
|
||||||
var bignum = bitcore.Bignum;
|
var bignum = bitcore.Bignum;
|
||||||
|
|
@ -865,22 +866,22 @@ Wallet.prototype._lockIncomming = function() {
|
||||||
|
|
||||||
Wallet.prototype._setBlockchainListeners = function() {
|
Wallet.prototype._setBlockchainListeners = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.blockchain.removeAllListeners();
|
self.blockchain.removeAllListeners();
|
||||||
|
|
||||||
this.blockchain.on('reconnect', function(attempts) {
|
self.blockchain.on('reconnect', function(attempts) {
|
||||||
log.debug('Wallet:' + this.id +'blockchain reconnect event');
|
log.debug('Wallet:' + self.id +'blockchain reconnect event');
|
||||||
self.emit('insightReconnected');
|
self.emit('insightReconnected');
|
||||||
|
|
||||||
// Subscription should persist? TODO
|
// Subscription should persist? TODO
|
||||||
//self.subscribeToAddresses();
|
//self.subscribeToAddresses();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.blockchain.on('disconnect', function() {
|
self.blockchain.on('disconnect', function() {
|
||||||
log.debug('Wallet:' + this.id +'blockchain disconnect event');
|
log.debug('Wallet:' + self.id +'blockchain disconnect event');
|
||||||
self.emit('insightError');
|
self.emit('insightError');
|
||||||
});
|
});
|
||||||
this.blockchain.on('tx', function(tx) {
|
self.blockchain.on('tx', function(tx) {
|
||||||
log.debug('Wallet:' + this.id +'blockchain tx event');
|
log.debug('Wallet:' + self.id +'blockchain tx event');
|
||||||
var addresses = self.getAddressesInfo();
|
var addresses = self.getAddressesInfo();
|
||||||
var addr = _.findWhere(addresses, {
|
var addr = _.findWhere(addresses, {
|
||||||
addressStr: tx.address
|
addressStr: tx.address
|
||||||
|
|
|
||||||
|
|
@ -419,20 +419,15 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
|
|
||||||
it('decodeSecret check', function() {
|
it('decodeSecret check', function() {
|
||||||
(function() {
|
var s = Wallet.decodeSecret('4fp61K187CsYmjoRQC5iAdC5eGmbCRsAAXfwEwetSQgHvZs27eWKaLaNHRoKM');
|
||||||
Wallet.decodeSecret('4fp61K187CsYmjoRQC5iAdC5eGmbCRsAAXfwEwetSQgHvZs27eWKaLaNHRoKM');
|
should.exist(s);
|
||||||
}).should.not.
|
|
||||||
throw();
|
|
||||||
|
|
||||||
(function() {
|
s= Wallet.decodeSecret('4fp61K187CsYmjoRQC5iAdC5eGmbCRsAAXfwEwetSQgHvZs27eWKaLaNHRoK');
|
||||||
Wallet.decodeSecret('4fp61K187CsYmjoRQC5iAdC5eGmbCRsAAXfwEwetSQgHvZs27eWKaLaNHRoK');
|
s.should.equal(false);
|
||||||
}).should.
|
|
||||||
throw();
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
Wallet.decodeSecret('12345');
|
s= Wallet.decodeSecret('123456');
|
||||||
}).should.
|
s.should.equal(false);
|
||||||
throw();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ describe('Identity model', function() {
|
||||||
|
|
||||||
wallet = sinon.stub();
|
wallet = sinon.stub();
|
||||||
wallet.store = sinon.stub().yields(null);
|
wallet.store = sinon.stub().yields(null);
|
||||||
|
wallet.netStart = sinon.stub();
|
||||||
wallet.getId = sinon.stub().returns('wid:123');
|
wallet.getId = sinon.stub().returns('wid:123');
|
||||||
Identity._newWallet = sinon.stub().returns(wallet);
|
Identity._newWallet = sinon.stub().returns(wallet);
|
||||||
|
|
||||||
|
|
@ -129,7 +130,7 @@ describe('Identity model', function() {
|
||||||
storage.getFirst = sinon.stub().yields('wallet1234');
|
storage.getFirst = sinon.stub().yields('wallet1234');
|
||||||
profile.listWallets = sinon.stub().returns([{id:'walletid'}]);
|
profile.listWallets = sinon.stub().returns([{id:'walletid'}]);
|
||||||
Identity._openProfile = sinon.stub().callsArgWith(3, null, profile);
|
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) {
|
it('should call ._openProfile', function(done) {
|
||||||
|
|
@ -234,7 +235,7 @@ describe('Identity model', function() {
|
||||||
var wallet = sinon.stub();
|
var wallet = sinon.stub();
|
||||||
wallet.store = sinon.stub().yields(null);
|
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) {
|
it('should return wallet and call .store, .setLastOpenedTs & .migrateWallet', function(done) {
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,10 @@
|
||||||
<li class="nav-item" ui-route="{{create}}">
|
<li class="nav-item" ui-route="{{create}}">
|
||||||
<a href="#!/join" class="db p20h" title="Join"><i class="size-21 m20r fi-torsos-all"></i> {{'Join' | translate }} </a>
|
<a href="#!/join" class="db p20h" title="Join"><i class="size-21 m20r fi-torsos-all"></i> {{'Join' | translate }} </a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item" ui-route="{{create}}">
|
||||||
|
<a href="#!/backup" class="db p20h" title="Create"><i class="size-21 m20r fi-download"></i> {{'Backup' | translate }} </a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#!/" class="db p20h" title="Close" ng-click="signout()"><i class="size-21 m20r fi-power"></i> {{'Close'|translate}}</a>
|
<a href="#!/" class="db p20h" title="Close" ng-click="signout()"><i class="size-21 m20r fi-power"></i> {{'Close'|translate}}</a>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue