From 2ff77801b0027d29b1c59dc345ee035f380fe8b2 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Fri, 15 Apr 2016 13:14:52 -0400 Subject: [PATCH] test: update address test and test upgrades --- lib/addresses.js | 5 ++--- lib/transactions.js | 6 +++--- package.json | 6 +++--- test/addresses.js | 35 ++++++++++++++++++++++++----------- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/lib/addresses.js b/lib/addresses.js index 7e82030..e30a7fb 100644 --- a/lib/addresses.js +++ b/lib/addresses.js @@ -51,7 +51,6 @@ AddressController.prototype.addressSummarySubQuery = function(req, res, param) { }; AddressController.prototype.getAddressSummary = function(address, options, callback) { - var self = this; this.node.getAddressSummary(address, options, function(err, summary) { if(err) { @@ -130,8 +129,8 @@ AddressController.prototype.utxo = function(req, res) { AddressController.prototype.multiutxo = function(req, res) { var self = this; - this.node.getUnspentOutputs(req.addrs, true, function(err, utxos) { - if(err && err instanceof self.node.errors.NoOutputs) { + this.node.getAddressUnspentOutputs(req.addrs, true, function(err, utxos) { + if(err && err.code === -5) { return res.jsonp([]); } else if(err) { return common.handleErrors(err, res); diff --git a/lib/transactions.js b/lib/transactions.js index 72320b9..a7c0bd0 100644 --- a/lib/transactions.js +++ b/lib/transactions.js @@ -139,9 +139,9 @@ TxController.prototype.transformOutput = function(output, index) { hex: output._scriptBuffer.toString('hex'), //reqSigs: null, // TODO }, - spentTxId: output.__spentTxId, - spentIndex: output.__spentIndex, - spentHeight: output.__spentHeight + spentTxId: output.__spentTxId || null, + spentIndex: output.__spentIndex || null, + spentHeight: output.__spentHeight || null //spentTs: undefined // TODO }; diff --git a/package.json b/package.json index 52e60e7..9432922 100644 --- a/package.json +++ b/package.json @@ -71,10 +71,10 @@ "request": "^2.64.0" }, "devDependencies": { - "chai": "*", - "mocha": "~1.16.2", + "chai": "^3.5.0", + "mocha": "^2.4.5", "proxyquire": "^1.7.2", - "should": "^2.1.1", + "should": "^8.3.1", "sinon": "^1.10.3" } } diff --git a/test/addresses.js b/test/addresses.js index 9b619be..54f3db1 100644 --- a/test/addresses.js +++ b/test/addresses.js @@ -334,6 +334,8 @@ describe('Addresses', function() { "ts": 1441116143, "scriptPubKey": "76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac", "amount": 0.5332, + "height": 534181, + "satoshis": 53320000, "confirmations": 50, "confirmationsFromCache": true }, @@ -344,6 +346,8 @@ describe('Addresses', function() { "ts": 1441116143, "scriptPubKey": "76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac", "amount": 0.00289829, + "height": 534181, + "satoshis": 289829, "confirmations": 50, "confirmationsFromCache": true } @@ -358,6 +362,11 @@ describe('Addresses', function() { ]; var node = { + services: { + bitcoind: { + height: 534230 + } + }, getAddressUnspentOutputs: sinon.stub().callsArgWith(2, null, utxos) }; @@ -432,7 +441,10 @@ describe('Addresses', function() { "addresses": [ "mxT2KzTUQvsaYYothDtjcdvyAdaHA9ofMp" ] - } + }, + "spentHeight": null, + "spentIndex": null, + "spentTxId": null }, { "value": "0.53320000", @@ -444,8 +456,11 @@ describe('Addresses', function() { "type": "pubkeyhash", "addresses": [ "mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK" - ] - } + ], + }, + "spentHeight": null, + "spentIndex": null, + "spentTxId": null }, { "value": "0.00289829", @@ -458,7 +473,10 @@ describe('Addresses', function() { "addresses": [ "moZY18rGNmh4YCPeugtGW46AkkWMQttBUD" ] - } + }, + "spentHeight": null, + "spentIndex": null, + "spentTxId": null } ], "blockhash": "0000000000000041ddc94ecf4f86a456a83b2e320c36c6f0c13ff92c7e75f013", @@ -524,13 +542,8 @@ describe('Addresses', function() { var node = { getAddressHistory: sinon.stub().callsArgWith(2, null, txinfos2), services: { - db: { - tip: { - __height: 534232 - } - }, - address: { - getInputForOutput: sinon.stub().callsArgWith(3, null, false), + bitcoind: { + height: 534232 } }, network: 'testnet'