Fixed tests.

This commit is contained in:
Chris Kleeschulte 2017-10-20 09:25:51 -04:00
parent 9f4ebfb1f9
commit e1305c7496
No known key found for this signature in database
GPG Key ID: 33195D27EF6BDB7F
3 changed files with 11 additions and 10 deletions

View File

@ -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 };

View File

@ -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});
});
});
});

View File

@ -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();
});
});