added test for pool.sendMessage
This commit is contained in:
parent
d63c1171db
commit
1dfe7091b4
21
test/pool.js
21
test/pool.js
@ -293,4 +293,25 @@ describe('Pool', function() {
|
||||
pool.connect();
|
||||
});
|
||||
|
||||
it('send message to all peers', function(done) {
|
||||
var message = 'message';
|
||||
var peerConnectStub = sinon.stub(Peer.prototype, 'connect', function() {
|
||||
var self = this;
|
||||
process.nextTick(function() {
|
||||
self.emit('ready');
|
||||
});
|
||||
});
|
||||
var peerMessageStub = sinon.stub(Peer.prototype, 'sendMessage', function(message) {
|
||||
message.should.equal(message);
|
||||
peerConnectStub.restore();
|
||||
peerMessageStub.restore();
|
||||
done();
|
||||
});
|
||||
var pool = new Pool({network: Networks.livenet, maxSize: 1});
|
||||
pool.on('peerready', function() {
|
||||
pool.sendMessage(message);
|
||||
});
|
||||
pool.connect();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user