Merge pull request #439 from braydonf/zmqcheck

bitcoind: added zmq precondition
This commit is contained in:
Chris Kleeschulte 2016-06-02 14:11:59 -04:00
commit e87f628e7a
2 changed files with 22 additions and 1 deletions

View File

@ -405,6 +405,11 @@ Bitcoin.prototype._checkConfigIndexes = function(spawnConfig, node) {
'Please add "zmqpubhashblock=tcp://127.0.0.1:<port>" to your configuration and restart' 'Please add "zmqpubhashblock=tcp://127.0.0.1:<port>" 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) { if (spawnConfig.reindex && spawnConfig.reindex === 1) {
log.warn('Reindex option is currently enabled. This means that bitcoind is undergoing a reindex. ' + 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 ' + 'The reindex flag will start the index from beginning every time the node is started, so it ' +

View File

@ -467,7 +467,7 @@ describe('Bitcoin Service', function() {
beforeEach(function() { beforeEach(function() {
sandbox.stub(log, 'warn'); sandbox.stub(log, 'warn');
}); });
after(function() { afterEach(function() {
sandbox.restore(); sandbox.restore();
}); });
it('should warn the user if reindex is set to 1 in the bitcoin.conf file', function() { 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); log.warn.callCount.should.equal(1);
node._reindex.should.equal(true); 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() { describe('#_resetCaches', function() {