add coverage
This commit is contained in:
parent
03ee93bac8
commit
824e8ee662
@ -102,6 +102,11 @@ var buildIOHelper = function(name) {
|
|||||||
return function(req, res) {
|
return function(req, res) {
|
||||||
$.checkState(req.tx instanceof Transaction);
|
$.checkState(req.tx instanceof Transaction);
|
||||||
if (_.isNumber(req.index)) {
|
if (_.isNumber(req.index)) {
|
||||||
|
if (req.index >= req.tx[name].length) {
|
||||||
|
res.status(404).send('Transaction ' + name.substring(0, name.length - 1) + ' ' + req.index +
|
||||||
|
' for ' + req.tx.id + ' not found, it only has ' + req.tx[name].length + ' ' + name + '.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
res.send(req.tx[name][req.index].toJSON());
|
res.send(req.tx[name][req.index].toJSON());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -136,6 +136,15 @@ describe('BitcoreHTTP v1 transactions routes', function() {
|
|||||||
for (var i = 0; i < tx[name].length; i++) {
|
for (var i = 0; i < tx[name].length; i++) {
|
||||||
it('works with valid txHash ...' + summary + ' ' + name + ' ' + i, canGetSpecificInput(i));
|
it('works with valid txHash ...' + summary + ' ' + name + ' ' + i, canGetSpecificInput(i));
|
||||||
}
|
}
|
||||||
|
it('fails with invalid ' + name + ' index ' + i + ' for txHash ...' + summary, function(cb) {
|
||||||
|
agent.get('/v1/transactions/' + hash + '/' + name + '/' + i)
|
||||||
|
.expect(404, cb);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('fails with invalid ' + name + ' format', function(cb) {
|
||||||
|
agent.get('/v1/transactions/' + t1.id + '/' + name + '/-1')
|
||||||
|
.expect(422)
|
||||||
|
.expect('index parameter must be a positive integer', cb);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user