diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index 4e79fcd6..7707303c 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -390,6 +390,11 @@ Bitcoin.prototype._checkConfigIndexes = function(spawnConfig, node) { 'Please add "zmqpubhashblock=tcp://127.0.0.1:" to your configuration and restart' ); + $.checkState( + (spawnConfig.zmqpubhashblock === spawnConfig.zmqpubrawtx), + '"zmqpubrawtx" and "zmqpubhashblock" are expected to the same host and port in bitcoin.conf' + ); + if (spawnConfig.reindex && spawnConfig.reindex === 1) { log.warn('Reindex option is currently enabled. This means that bitcoind is undergoing a reindex. ' + 'The reindex flag will start the index from beginning every time the node is started, so it ' + diff --git a/test/services/bitcoind.unit.js b/test/services/bitcoind.unit.js index 8719f7f5..00f616ef 100644 --- a/test/services/bitcoind.unit.js +++ b/test/services/bitcoind.unit.js @@ -429,7 +429,7 @@ describe('Bitcoin Service', function() { beforeEach(function() { sandbox.stub(log, 'warn'); }); - after(function() { + afterEach(function() { sandbox.restore(); }); it('should warn the user if reindex is set to 1 in the bitcoin.conf file', function() { @@ -448,6 +448,22 @@ describe('Bitcoin Service', function() { log.warn.callCount.should.equal(1); node._reindex.should.equal(true); }); + it('should warn if zmq port and hosts do not match', function() { + var bitcoind = new BitcoinService(baseConfig); + var config = { + txindex: 1, + addressindex: 1, + spentindex: 1, + server: 1, + zmqpubrawtx: 'tcp://127.0.0.1:28332', + zmqpubhashblock: 'tcp://127.0.0.1:28331', + reindex: 1 + }; + var node = {}; + (function() { + bitcoind._checkConfigIndexes(config, node); + }).should.throw('"zmqpubrawtx" and "zmqpubhashblock"'); + }); }); describe('#_resetCaches', function() {