Fixed typo and added a test to prove that the inputs from the mempoolInputIndex are added on stream close.
This commit is contained in:
parent
6b904dda70
commit
0ba168e2a2
|
@ -648,7 +648,7 @@ AddressService.prototype.getInputs = function(addressStr, options, callback) {
|
|||
if (mempoolInputs) {
|
||||
for(var i = 0; i < mempoolInputs.length; i++) {
|
||||
// TODO copy
|
||||
var newInput = mempooInputs[i];
|
||||
var newInput = mempoolInputs[i];
|
||||
newInput.address = addressStr;
|
||||
newInput.height = -1;
|
||||
newInput.confirmations = 0;
|
||||
|
|
|
@ -412,6 +412,43 @@ describe('Address Service', function() {
|
|||
am = new AddressService({node: testnode});
|
||||
});
|
||||
|
||||
it('will add mempool inputs on close', function(done) {
|
||||
var testStream = new EventEmitter();
|
||||
var db = {
|
||||
store: {
|
||||
createReadStream: sinon.stub().returns(testStream)
|
||||
}
|
||||
}
|
||||
var testnode = {
|
||||
services: {
|
||||
db: db,
|
||||
bitcoind: {
|
||||
on: sinon.stub()
|
||||
}
|
||||
}
|
||||
};
|
||||
var am = new AddressService({node: testnode});
|
||||
var args = {
|
||||
start: 15,
|
||||
end: 12,
|
||||
queryMempool: true
|
||||
};
|
||||
am.mempoolInputIndex[address] = [
|
||||
{
|
||||
address: address,
|
||||
height: -1,
|
||||
confirmations: 0
|
||||
}
|
||||
]
|
||||
am.getInputs(address, args, function(err, inputs) {
|
||||
should.not.exist(err);
|
||||
inputs.length.should.equal(1);
|
||||
inputs[0].address.should.equal(address);
|
||||
inputs[0].height.should.equal(-1);
|
||||
done();
|
||||
});
|
||||
testStream.emit('close');
|
||||
});
|
||||
it('will get inputs for an address and timestamp', function(done) {
|
||||
var testStream = new EventEmitter();
|
||||
var args = {
|
||||
|
|
Loading…
Reference in New Issue