From 52cf30085834c1bfdc81309c6c9a68ccecd4e85f Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Tue, 24 May 2016 15:13:41 -0400 Subject: [PATCH] test: coverage for bitcoind getAddressSummary --- test/services/bitcoind.unit.js | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/services/bitcoind.unit.js b/test/services/bitcoind.unit.js index 2706cd0f..39ef2296 100644 --- a/test/services/bitcoind.unit.js +++ b/test/services/bitcoind.unit.js @@ -3198,6 +3198,54 @@ describe('Bitcoin Service', function() { }); }); }); + it('will skip querying the mempool with queryMempool set to false', function(done) { + var bitcoind = new BitcoinService(baseConfig); + var getAddressMempool = sinon.stub(); + bitcoind.nodes.push({ + client: { + getAddressMempool: getAddressMempool + } + }); + sinon.spy(bitcoind, '_paginateTxids'); + bitcoind.getAddressTxids = sinon.stub().callsArgWith(2, null, [txid1, txid2, txid3]); + bitcoind.getAddressBalance = sinon.stub().callsArgWith(2, null, { + received: 30 * 1e8, + balance: 20 * 1e8 + }); + var address = '3NbU8XzUgKyuCgYgZEKsBtUvkTm2r7Xgwj'; + var options = { + queryMempool: false + }; + bitcoind.getAddressSummary(address, options, function() { + getAddressMempool.callCount.should.equal(0); + done(); + }); + }); + it('will give error from _paginateTxids', function(done) { + var bitcoind = new BitcoinService(baseConfig); + var getAddressMempool = sinon.stub(); + bitcoind.nodes.push({ + client: { + getAddressMempool: getAddressMempool + } + }); + sinon.spy(bitcoind, '_paginateTxids'); + bitcoind.getAddressTxids = sinon.stub().callsArgWith(2, null, [txid1, txid2, txid3]); + bitcoind.getAddressBalance = sinon.stub().callsArgWith(2, null, { + received: 30 * 1e8, + balance: 20 * 1e8 + }); + bitcoind._paginateTxids = sinon.stub().throws(new Error('test')); + var address = '3NbU8XzUgKyuCgYgZEKsBtUvkTm2r7Xgwj'; + var options = { + queryMempool: false + }; + bitcoind.getAddressSummary(address, options, function(err) { + err.should.be.instanceOf(Error); + err.message.should.equal('test'); + done(); + }); + }); }); describe('#getRawBlock', function() {