sort in descending order
@ -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;
};
@ -2351,30 +2351,30 @@ describe('Copay server', function() {
minTs: 15,
maxTs: 45,
},
expected: [20, 30, 40],
expected: [40, 30, 20],
}, {
opts: {
limit: 2,
expected: [20, 30],
expected: [40, 30],
maxTs: 35,
expected: [10, 20, 30],
expected: [30, 20, 10],
expected: [20, 30, 40, 50],
expected: [50, 40, 30, 20],
limit: 3,
expected: [50, 40, 30],
}];
server._normalizeTxHistory = sinon.stub().returnsArg(0);