From 0c24271833885405b919e318c3e5ca3bca68f842 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sun, 11 Feb 2018 19:47:52 -0300 Subject: [PATCH] change order to 'desc' --- lib/services/address/index.js | 2 +- test/services/address/index.unit.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/services/address/index.js b/lib/services/address/index.js index d48d82f1..97144473 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -79,7 +79,7 @@ AddressService.prototype.getAddressHistory = function(addresses, options, callba }); - options.txIdList = lodash.sortBy(list,['height','txid']); + options.txIdList = lodash.orderBy(list,['height','txid'], ['desc','asc']); self._getAddressTxHistory(options, function(err, txList) { if (err) { diff --git a/test/services/address/index.unit.js b/test/services/address/index.unit.js index 89544405..5ded3800 100644 --- a/test/services/address/index.unit.js +++ b/test/services/address/index.unit.js @@ -81,19 +81,19 @@ describe('Address Service', function() { addressService._getAddressTxidHistory = function(addr, options, cb) { options.txIdList = [ { - txid: "b", + txid: "d", + height: 10, + }, + { + txid: "c", height: 10, }, { txid: "a", - height: 10, - }, - { - txid: "d", height: 101, }, { - txid: "c", + txid: "b", height: 100, }, ]; @@ -163,7 +163,7 @@ describe('Address Service', function() { } expect(res.totalCount).equal(3); - expect(lodash.map(res.items,'txid')).to.be.deep.equal(['b','c','d']); + expect(lodash.map(res.items,'txid')).to.be.deep.equal(['d','c','b']); addressService._getAddressTxidHistory = old_getAddressTxHistory; addressService._getAddressTxHistory = old_getAddressTxHistory;