fix insight tests
This commit is contained in:
parent
d838a29d02
commit
194913c561
2 changed files with 17 additions and 18 deletions
|
|
@ -30,9 +30,16 @@ FakeSocket.prototype.removeEventListener = function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FakeSocket.prototype.destroy = function() {
|
FakeSocket.prototype.destroy = function() {
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
this.removeAllListeners();
|
this.removeAllListeners();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
FakeSocket.prototype.disconnect = function() {
|
||||||
|
this.destroy();
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = FakeSocket;
|
module.exports = FakeSocket;
|
||||||
|
|
@ -79,9 +79,9 @@ describe('Insight model', function() {
|
||||||
var socket = blockchain.getSocket();
|
var socket = blockchain.getSocket();
|
||||||
blockchain.on('connect', function() {
|
blockchain.on('connect', function() {
|
||||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||||
blockchain.getSubscriptions().length.should.equal(1);
|
Object.keys(blockchain.getSubscriptions()).length.should.equal(1);
|
||||||
blockchain.destroy();
|
blockchain.destroy();
|
||||||
blockchain.getSubscriptions().length.should.equal(0);
|
Object.keys(blockchain.getSubscriptions()).length.should.equal(0);
|
||||||
blockchain.status.should.be.equal('destroyed');
|
blockchain.status.should.be.equal('destroyed');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
@ -93,7 +93,7 @@ describe('Insight model', function() {
|
||||||
var emitSpy = sinon.spy(socket, 'emit');
|
var emitSpy = sinon.spy(socket, 'emit');
|
||||||
|
|
||||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||||
blockchain.getSubscriptions().length.should.equal(1);
|
Object.keys(blockchain.getSubscriptions()).length.should.equal(1);
|
||||||
emitSpy.calledWith('subscribe', 'mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
emitSpy.calledWith('subscribe', 'mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ describe('Insight model', function() {
|
||||||
|
|
||||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||||
blockchain.getSubscriptions().length.should.equal(1);
|
Object.keys(blockchain.getSubscriptions()).length.should.equal(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should subscribe to a list of addresses', function() {
|
it('should subscribe to a list of addresses', function() {
|
||||||
|
|
@ -114,27 +114,19 @@ describe('Insight model', function() {
|
||||||
'mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM',
|
'mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM',
|
||||||
'2NBBHBjB5sd7HFqKtout1L7d6dPhwJgP2j8'
|
'2NBBHBjB5sd7HFqKtout1L7d6dPhwJgP2j8'
|
||||||
]);
|
]);
|
||||||
blockchain.getSubscriptions().length.should.equal(2);
|
Object.keys(blockchain.getSubscriptions()).length.should.equal(2);
|
||||||
emitSpy.calledWith('subscribe', 'mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
emitSpy.calledWith('subscribe', 'mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||||
emitSpy.calledWith('subscribe', '2NBBHBjB5sd7HFqKtout1L7d6dPhwJgP2j8');
|
emitSpy.calledWith('subscribe', '2NBBHBjB5sd7HFqKtout1L7d6dPhwJgP2j8');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should unsubscribe to an address', function() {
|
it('should resubscribe to all addresses', function() {
|
||||||
var blockchain = new Insight(FAKE_OPTS);
|
|
||||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
|
||||||
blockchain.getSubscriptions().length.should.equal(1);
|
|
||||||
blockchain.unsubscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
|
||||||
blockchain.getSubscriptions().length.should.equal(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should unsubscribe to all addresses', function() {
|
|
||||||
var blockchain = new Insight(FAKE_OPTS);
|
var blockchain = new Insight(FAKE_OPTS);
|
||||||
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
blockchain.subscribe('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
||||||
blockchain.subscribe('2NBBHBjB5sd7HFqKtout1L7d6dPhwJgP2j8');
|
blockchain.subscribe('2NBBHBjB5sd7HFqKtout1L7d6dPhwJgP2j8');
|
||||||
blockchain.getSubscriptions().length.should.equal(2);
|
Object.keys(blockchain.getSubscriptions()).length.should.equal(2);
|
||||||
|
|
||||||
blockchain.unsubscribeAll('mg7UbtKgMvWAixTNMbC8soyUnwFk1qxEuM');
|
blockchain.reSubscribe();
|
||||||
blockchain.getSubscriptions().length.should.equal(0);
|
Object.keys(blockchain.getSubscriptions()).length.should.equal(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should broadcast a raw transaction', function(done) {
|
it('should broadcast a raw transaction', function(done) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue