From 801651d494f23f6f3211d977b067c010288c2148 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 13 Jan 2014 20:38:51 -0300 Subject: [PATCH] all addr test OK --- app/models/Address.js | 4 ++-- test/model/addr.js | 3 ++- test/model/addr.json | 8 ++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/models/Address.js b/app/models/Address.js index ce6cccb6..b01cc2d2 100644 --- a/app/models/Address.js +++ b/app/models/Address.js @@ -54,12 +54,12 @@ function spec() { // TODO TXout! //T function (cb) { - TransactionItem.find({addr:that.addrStr}, function(err,txItems){ + TransactionItem.find({addr:that.addrStr}).sort({ts:1}).exec(function(err,txItems){ if (err) return cb(err); txItems.forEach(function(txItem){ - // console.log(txItem.txid + ' : ' + txItem.value_sat); +// console.log(txItem.txid + ':' + txItem.ts+ ' : ' + (txItem.value_sat/parseFloat(BitcoreUtil.COIN) ) ); that.txApperances +=1; that.balanceSat += txItem.value_sat; diff --git a/test/model/addr.js b/test/model/addr.js index c19988e5..1a300f1e 100644 --- a/test/model/addr.js +++ b/test/model/addr.js @@ -41,8 +41,9 @@ describe('Address balances', function(){ if (v.totalReceived) assert.equal(v.totalReceived, a.totalReceived); if (v.totalSent) assert.equal(v.totalSent, a.totalSent); if (v.transactions) { + v.transactions.forEach( function(tx) { - assert(tx in a.transactions); + assert(a.transactions.indexOf(tx)>-1); }); } done(); diff --git a/test/model/addr.json b/test/model/addr.json index b6c8a15f..d5408ba7 100644 --- a/test/model/addr.json +++ b/test/model/addr.json @@ -34,21 +34,18 @@ "totalSent": 3.9775 }, { -"disabled":1, "addr": "mzW2hdZN2um7WBvTDerdahKqRgj3md9C29", - "balance": 910.39522682, - "totalReceived": 910.39522682, + "balance": 910.3952268, + "totalReceived": 910.3952268, "totalSent": 0 }, { -"disabled":1, "addr": "mjRmkmYzvZN3cA3aBKJgYJ65epn3WCG84H", "balance": 46413.0, "totalReceived": 357130.17644359, "totalSent": 310717.17644359 }, { -"disabled":1, "addr": "mgKY35SXqxFpcKK3Dq9mW9919N7wYXvcFM", "balance": 0.01979459, "totalReceived": 0.01979459, @@ -56,7 +53,6 @@ "transactions": [ "91800d80bb4c69b238c9bfd94eb5155ab821e6b25cae5c79903d12853bbb4ed5" ] }, { -"disabled":1, "addr": "mmvP3mTe53qxHdPqXEvdu8WdC7GfQ2vmx5", "balance": 10580.50027254, "totalReceived": 12157.65075053,