From e1305c7496a7ae085c6e582537ef59eaeec6ed40 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Fri, 20 Oct 2017 09:25:51 -0400 Subject: [PATCH] Fixed tests. --- test/services/address/index.unit.js | 4 ++-- test/services/mempool/encoding.unit.js | 9 +++++---- test/services/mempool/index.unit.js | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/services/address/index.unit.js b/test/services/address/index.unit.js index 646afbd1..a8a9e90a 100644 --- a/test/services/address/index.unit.js +++ b/test/services/address/index.unit.js @@ -81,7 +81,7 @@ describe('Address Service', function() { var getHeaderHash = sandbox.stub().callsArgWith(1, null, 'aa'); var getBlockHeader = sandbox.stub().callsArgWith(1, null, 'aa'); - var getTxsByAddress = sandbox.stub().callsArgWith(1, null, []); + var getTxsByAddress = sandbox.stub().callsArgWith(2, null, []); var getTransaction = sandbox.stub().callsArgWith(2, null, { __height: 123, outputs: [ { value: 1 } ], __inputValues: [ 1 ] }); addressService._transaction = { getTransaction: getTransaction }; @@ -181,7 +181,7 @@ describe('Address Service', function() { var txidStream = new EventEmitter(); - addressService._mempool = { getTxsByAddress: sinon.stub().callsArgWith(1, null, []) }; + addressService._mempool = { getTxsByAddress: sinon.stub().callsArgWith(2, null, []) }; var createReadStream = sandbox.stub().returns(txidStream); addressService._db = { createReadStream: createReadStream }; diff --git a/test/services/mempool/encoding.unit.js b/test/services/mempool/encoding.unit.js index 744eb0dd..309e557a 100644 --- a/test/services/mempool/encoding.unit.js +++ b/test/services/mempool/encoding.unit.js @@ -42,7 +42,7 @@ describe('Block service encoding', function() { it('should encode mempool address key', function() { - encoding.encodeMempoolAddressKey(address, hash, 0, 1, now) + encoding.encodeMempoolAddressKey(address, hash, 0, 1) .should.deep.equal(Buffer.concat([ servicePrefix, addressPrefix, @@ -50,7 +50,8 @@ describe('Block service encoding', function() { new Buffer(address), new Buffer(hash, 'hex'), new Buffer('00000000', 'hex'), - new Buffer('01', 'hex'), nowBuf ])); + new Buffer('01', 'hex') + ])); }); it('should decode mempool address key', function() { @@ -61,12 +62,12 @@ describe('Block service encoding', function() { new Buffer(address), new Buffer(hash, 'hex'), new Buffer('00000000', 'hex'), - new Buffer('01', 'hex'), nowBuf ])).should.deep.equal({ + new Buffer('01', 'hex') ])).should.deep.equal({ address: address, txid: hash, index: 0, input: 1, - timestamp: now}); + }); }); }); diff --git a/test/services/mempool/index.unit.js b/test/services/mempool/index.unit.js index 748197b3..beb57053 100644 --- a/test/services/mempool/index.unit.js +++ b/test/services/mempool/index.unit.js @@ -73,10 +73,10 @@ describe('Mempool Service', function() { describe('#_onTransaction', function() { it('should add the transaction to the database', function() { - var put = sandbox.stub(); - mempoolService._db = { put: put }; + var batch = sandbox.stub(); + mempoolService._db = { batch: batch }; mempoolService._onTransaction(tx); - expect(put.calledOnce).to.be.true; + expect(batch.calledOnce).to.be.true; }); }); @@ -84,7 +84,7 @@ describe('Mempool Service', function() { it('should remove block\'s txs from database', function(done) { mempoolService.onBlock(block, function(err, ops) { expect(ops[0].type).to.deep.equal('del'); - expect(ops[0].key.toString('hex')).to.deep.equal('00006321fd1cf3fbf32a41bbb47b7090ab9896bbe6093e4c342c0269b652fa800c2b'); + expect(ops[0].key.toString('hex')).to.deep.equal('0000006321fd1cf3fbf32a41bbb47b7090ab9896bbe6093e4c342c0269b652fa800c2b'); done(); }); });