enforce txhistory limit

This commit is contained in:
Matias Alejo Garcia 2015-12-14 16:41:06 -03:00
parent 4eb3caea00
commit 0968de59dd
3 changed files with 11 additions and 2 deletions

View File

@ -17,6 +17,7 @@ var errors = {
INVALID_ADDRESS: 'Invalid address',
KEY_IN_COPAYER: 'Key already registered',
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',
NOT_AUTHORIZED: 'Not authorized',
TOO_MANY_KEYS: 'Too many keys registered',

View File

@ -1975,7 +1975,8 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
opts = opts || {};
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) {

View File

@ -4415,7 +4415,7 @@ describe('Wallet service', function() {
}, {
opts: {
skip: 4,
limit: 20,
limit: 10,
},
expected: [10],
}, {
@ -4479,6 +4479,13 @@ describe('Wallet service', function() {
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() {