enforce txhistory limit
This commit is contained in:
parent
4eb3caea00
commit
0968de59dd
|
@ -17,6 +17,7 @@ var errors = {
|
||||||
INVALID_ADDRESS: 'Invalid address',
|
INVALID_ADDRESS: 'Invalid address',
|
||||||
KEY_IN_COPAYER: 'Key already registered',
|
KEY_IN_COPAYER: 'Key already registered',
|
||||||
LOCKED_FUNDS: 'Funds are locked by pending transaction proposals',
|
LOCKED_FUNDS: 'Funds are locked by pending transaction proposals',
|
||||||
|
HISTORY_LIMIT_EXCEEDED: 'Requested page limit is above allowed maximum',
|
||||||
MAIN_ADDRESS_GAP_REACHED: 'Maximum number of consecutive addresses without activity reached',
|
MAIN_ADDRESS_GAP_REACHED: 'Maximum number of consecutive addresses without activity reached',
|
||||||
NOT_AUTHORIZED: 'Not authorized',
|
NOT_AUTHORIZED: 'Not authorized',
|
||||||
TOO_MANY_KEYS: 'Too many keys registered',
|
TOO_MANY_KEYS: 'Too many keys registered',
|
||||||
|
|
|
@ -1975,7 +1975,8 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
|
||||||
|
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
opts.limit = (_.isUndefined(opts.limit) ? HISTORY_LIMIT : opts.limit);
|
opts.limit = (_.isUndefined(opts.limit) ? HISTORY_LIMIT : opts.limit);
|
||||||
if (opts.limit > HISTORY_LIMIT) opts.limit = HISTORY_LIMIT;
|
if (opts.limit > HISTORY_LIMIT)
|
||||||
|
return cb(Errors.HISTORY_LIMIT_EXCEEDED);
|
||||||
|
|
||||||
function decorate(txs, addresses, proposals) {
|
function decorate(txs, addresses, proposals) {
|
||||||
|
|
||||||
|
|
|
@ -4415,7 +4415,7 @@ describe('Wallet service', function() {
|
||||||
}, {
|
}, {
|
||||||
opts: {
|
opts: {
|
||||||
skip: 4,
|
skip: 4,
|
||||||
limit: 20,
|
limit: 10,
|
||||||
},
|
},
|
||||||
expected: [10],
|
expected: [10],
|
||||||
}, {
|
}, {
|
||||||
|
@ -4479,6 +4479,13 @@ describe('Wallet service', function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('should handle exceeded limit', function(done) {
|
||||||
|
server.getTxHistory({limit:1000}, function(err, txs) {
|
||||||
|
err.code.should.equal('HISTORY_LIMIT_EXCEEDED');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#scan', function() {
|
describe('#scan', function() {
|
||||||
|
|
Loading…
Reference in New Issue