Add reconnecting notification, change subscribed list to dict, update balance after reconnect
This commit is contained in:
parent
0623c87727
commit
b97a332ae9
6 changed files with 49 additions and 26 deletions
|
|
@ -36,7 +36,10 @@ var FakeWallet = function() {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
this.blockchain = {subscribed: [], subscribe: function(){}};
|
||||
this.blockchain = {
|
||||
getSubscriptions: function(){ return []; },
|
||||
subscribe: function(){}
|
||||
};
|
||||
|
||||
this.privateKey = new FakePrivateKey();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -77,9 +77,9 @@ describe('Insight model', function() {
|
|||
blockchain.status.should.be.equal('disconnected');
|
||||
blockchain.on('connect', function() {
|
||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||
blockchain.subscribed.length.should.equal(1);
|
||||
blockchain.getSubscriptions().length.should.equal(1);
|
||||
blockchain.destroy();
|
||||
blockchain.subscribed.length.should.equal(0);
|
||||
blockchain.getSubscriptions().length.should.equal(0);
|
||||
blockchain.status.should.be.equal('destroyed');
|
||||
done();
|
||||
});
|
||||
|
|
@ -90,7 +90,7 @@ describe('Insight model', function() {
|
|||
var emitSpy = sinon.spy(blockchain.socket, 'emit');
|
||||
|
||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||
blockchain.subscribed.length.should.equal(1);
|
||||
blockchain.getSubscriptions().length.should.equal(1);
|
||||
emitSpy.calledWith('subscribe', 'mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||
});
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ describe('Insight model', function() {
|
|||
|
||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||
blockchain.subscribed.length.should.equal(1);
|
||||
blockchain.getSubscriptions().length.should.equal(1);
|
||||
});
|
||||
|
||||
it('should subscribe to a list of addresses', function() {
|
||||
|
|
@ -110,7 +110,7 @@ describe('Insight model', function() {
|
|||
'mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM',
|
||||
'2NBBHBjB5sd7HFqKtout1L7d6dPhwJgP2j8'
|
||||
]);
|
||||
blockchain.subscribed.length.should.equal(2);
|
||||
blockchain.getSubscriptions().length.should.equal(2);
|
||||
emitSpy.calledWith('subscribe', 'mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||
emitSpy.calledWith('subscribe', '2NBBHBjB5sd7HFqKtout1L7d6dPhwJgP2j8');
|
||||
});
|
||||
|
|
@ -118,19 +118,19 @@ describe('Insight model', function() {
|
|||
it('should unsubscribe to an address', function() {
|
||||
var blockchain = new Insight(FAKE_OPTS);
|
||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||
blockchain.subscribed.length.should.equal(1);
|
||||
blockchain.getSubscriptions().length.should.equal(1);
|
||||
blockchain.unsubscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||
blockchain.subscribed.length.should.equal(0);
|
||||
blockchain.getSubscriptions().length.should.equal(0);
|
||||
});
|
||||
|
||||
it('should unsubscribe to all addresses', function() {
|
||||
var blockchain = new Insight(FAKE_OPTS);
|
||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||
blockchain.subscribe('2NBBHBjB5sd7HFqKtout1L7d6dPhwJgP2j8');
|
||||
blockchain.subscribed.length.should.equal(2);
|
||||
blockchain.getSubscriptions().length.should.equal(2);
|
||||
|
||||
blockchain.unsubscribeAll('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||
blockchain.subscribed.length.should.equal(0);
|
||||
blockchain.getSubscriptions().length.should.equal(0);
|
||||
});
|
||||
|
||||
it('should broadcast a raw transaction', function(done) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue