Browse Source

Merge pull request #147 from isocolsky/feat/history_pagination

sort in descending order
activeAddress
Gustavo Maximiliano Cortez 10 years ago
parent
commit
e6956d6830
  1. 4
      lib/server.js
  2. 10
      test/integration/server.js

4
lib/server.js

@ -1009,7 +1009,9 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
var filtered = _.sortBy(_.filter(txs, function(tx) {
return tx.time >= minTs && tx.time <= maxTs;
}), 'time');
}), function(tx) {
return -tx.time;
});
return limited ? _.take(filtered, opts.limit) : filtered;
};

10
test/integration/server.js

@ -2351,30 +2351,30 @@ describe('Copay server', function() {
minTs: 15,
maxTs: 45,
},
expected: [20, 30, 40],
expected: [40, 30, 20],
}, {
opts: {
minTs: 15,
maxTs: 45,
limit: 2,
},
expected: [20, 30],
expected: [40, 30],
}, {
opts: {
maxTs: 35,
},
expected: [10, 20, 30],
expected: [30, 20, 10],
}, {
opts: {
minTs: 15,
},
expected: [20, 30, 40, 50],
expected: [50, 40, 30, 20],
}, {
opts: {
minTs: 15,
limit: 3,
},
expected: [20, 30, 40],
expected: [50, 40, 30],
}];
server._normalizeTxHistory = sinon.stub().returnsArg(0);

Loading…
Cancel
Save