diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index f1e21464..fd0ee0b4 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -405,6 +405,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 f486113a..4f602649 100644 --- a/test/services/bitcoind.unit.js +++ b/test/services/bitcoind.unit.js @@ -467,7 +467,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() { @@ -486,6 +486,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() {