test: update address test and test upgrades

This commit is contained in:
Braydon Fuller 2016-04-15 13:14:52 -04:00
parent bb901b91bc
commit 2ff77801b0
4 changed files with 32 additions and 20 deletions

View File

@ -51,7 +51,6 @@ AddressController.prototype.addressSummarySubQuery = function(req, res, param) {
}; };
AddressController.prototype.getAddressSummary = function(address, options, callback) { AddressController.prototype.getAddressSummary = function(address, options, callback) {
var self = this;
this.node.getAddressSummary(address, options, function(err, summary) { this.node.getAddressSummary(address, options, function(err, summary) {
if(err) { if(err) {
@ -130,8 +129,8 @@ AddressController.prototype.utxo = function(req, res) {
AddressController.prototype.multiutxo = function(req, res) { AddressController.prototype.multiutxo = function(req, res) {
var self = this; var self = this;
this.node.getUnspentOutputs(req.addrs, true, function(err, utxos) { this.node.getAddressUnspentOutputs(req.addrs, true, function(err, utxos) {
if(err && err instanceof self.node.errors.NoOutputs) { if(err && err.code === -5) {
return res.jsonp([]); return res.jsonp([]);
} else if(err) { } else if(err) {
return common.handleErrors(err, res); return common.handleErrors(err, res);

View File

@ -139,9 +139,9 @@ TxController.prototype.transformOutput = function(output, index) {
hex: output._scriptBuffer.toString('hex'), hex: output._scriptBuffer.toString('hex'),
//reqSigs: null, // TODO //reqSigs: null, // TODO
}, },
spentTxId: output.__spentTxId, spentTxId: output.__spentTxId || null,
spentIndex: output.__spentIndex, spentIndex: output.__spentIndex || null,
spentHeight: output.__spentHeight spentHeight: output.__spentHeight || null
//spentTs: undefined // TODO //spentTs: undefined // TODO
}; };

View File

@ -71,10 +71,10 @@
"request": "^2.64.0" "request": "^2.64.0"
}, },
"devDependencies": { "devDependencies": {
"chai": "*", "chai": "^3.5.0",
"mocha": "~1.16.2", "mocha": "^2.4.5",
"proxyquire": "^1.7.2", "proxyquire": "^1.7.2",
"should": "^2.1.1", "should": "^8.3.1",
"sinon": "^1.10.3" "sinon": "^1.10.3"
} }
} }

View File

@ -334,6 +334,8 @@ describe('Addresses', function() {
"ts": 1441116143, "ts": 1441116143,
"scriptPubKey": "76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac", "scriptPubKey": "76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac",
"amount": 0.5332, "amount": 0.5332,
"height": 534181,
"satoshis": 53320000,
"confirmations": 50, "confirmations": 50,
"confirmationsFromCache": true "confirmationsFromCache": true
}, },
@ -344,6 +346,8 @@ describe('Addresses', function() {
"ts": 1441116143, "ts": 1441116143,
"scriptPubKey": "76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac", "scriptPubKey": "76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac",
"amount": 0.00289829, "amount": 0.00289829,
"height": 534181,
"satoshis": 289829,
"confirmations": 50, "confirmations": 50,
"confirmationsFromCache": true "confirmationsFromCache": true
} }
@ -358,6 +362,11 @@ describe('Addresses', function() {
]; ];
var node = { var node = {
services: {
bitcoind: {
height: 534230
}
},
getAddressUnspentOutputs: sinon.stub().callsArgWith(2, null, utxos) getAddressUnspentOutputs: sinon.stub().callsArgWith(2, null, utxos)
}; };
@ -432,7 +441,10 @@ describe('Addresses', function() {
"addresses": [ "addresses": [
"mxT2KzTUQvsaYYothDtjcdvyAdaHA9ofMp" "mxT2KzTUQvsaYYothDtjcdvyAdaHA9ofMp"
] ]
} },
"spentHeight": null,
"spentIndex": null,
"spentTxId": null
}, },
{ {
"value": "0.53320000", "value": "0.53320000",
@ -444,8 +456,11 @@ describe('Addresses', function() {
"type": "pubkeyhash", "type": "pubkeyhash",
"addresses": [ "addresses": [
"mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK" "mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK"
] ],
} },
"spentHeight": null,
"spentIndex": null,
"spentTxId": null
}, },
{ {
"value": "0.00289829", "value": "0.00289829",
@ -458,7 +473,10 @@ describe('Addresses', function() {
"addresses": [ "addresses": [
"moZY18rGNmh4YCPeugtGW46AkkWMQttBUD" "moZY18rGNmh4YCPeugtGW46AkkWMQttBUD"
] ]
} },
"spentHeight": null,
"spentIndex": null,
"spentTxId": null
} }
], ],
"blockhash": "0000000000000041ddc94ecf4f86a456a83b2e320c36c6f0c13ff92c7e75f013", "blockhash": "0000000000000041ddc94ecf4f86a456a83b2e320c36c6f0c13ff92c7e75f013",
@ -524,13 +542,8 @@ describe('Addresses', function() {
var node = { var node = {
getAddressHistory: sinon.stub().callsArgWith(2, null, txinfos2), getAddressHistory: sinon.stub().callsArgWith(2, null, txinfos2),
services: { services: {
db: { bitcoind: {
tip: { height: 534232
__height: 534232
}
},
address: {
getInputForOutput: sinon.stub().callsArgWith(3, null, false),
} }
}, },
network: 'testnet' network: 'testnet'