Fixed tests.
This commit is contained in:
parent
9f4ebfb1f9
commit
e1305c7496
@ -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 };
|
||||
|
||||
|
||||
@ -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});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user