bitcoind: emit block events while polling before subscribing to zmq events
This commit is contained in:
parent
b092adcc21
commit
458fe2f2b6
@ -443,6 +443,7 @@ Bitcoin.prototype._checkSyncedAndSubscribeZmqEvents = function(node) {
|
||||
return callback(self._wrapRPCError(err));
|
||||
}
|
||||
var blockhash = new Buffer(response.result, 'hex');
|
||||
self.emit('block', blockhash);
|
||||
self._updateTip(node, blockhash);
|
||||
|
||||
// check if synced
|
||||
|
||||
@ -681,6 +681,10 @@ describe('Bitcoin Service', function() {
|
||||
var bitcoind = new BitcoinService(baseConfig);
|
||||
bitcoind._updateTip = sinon.stub();
|
||||
bitcoind._subscribeZmqEvents = sinon.stub();
|
||||
var blockEvents = 0;
|
||||
bitcoind.on('block', function() {
|
||||
blockEvents++;
|
||||
});
|
||||
var getBestBlockHash = sinon.stub().callsArgWith(0, null, {
|
||||
result: '00000000000000001bb82a7f5973618cfd3185ba1ded04dd852a653f92a27c45'
|
||||
});
|
||||
@ -712,6 +716,7 @@ describe('Bitcoin Service', function() {
|
||||
bitcoind._checkSyncedAndSubscribeZmqEvents(node);
|
||||
setTimeout(function() {
|
||||
log.error.callCount.should.equal(2);
|
||||
blockEvents.should.equal(10);
|
||||
bitcoind._updateTip.callCount.should.equal(10);
|
||||
bitcoind._subscribeZmqEvents.callCount.should.equal(1);
|
||||
done();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user