From 662e53aaa2786be019838ac4b3258c9127868462 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Thu, 13 Aug 2020 15:44:26 -0700 Subject: [PATCH 1/2] debugging ninsight test --- test/integration/ninsight.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/test/integration/ninsight.js b/test/integration/ninsight.js index 8934617..726d677 100644 --- a/test/integration/ninsight.js +++ b/test/integration/ninsight.js @@ -12,26 +12,30 @@ describe(`#Ninsight`, () => { describe(`#utxo`, () => { it(`should GET utxos for a single address`, async () => { - const addr = "bitcoincash:qqh793x9au6ehvh7r2zflzguanlme760wuzehgzjh9" + try { + const addr = "bitcoincash:qqh793x9au6ehvh7r2zflzguanlme760wuzehgzjh9" - const result = await bchjs.Ninsight.utxo(addr) - // console.log(`result: ${JSON.stringify(result, null, 2)}`) + const result = await bchjs.Ninsight.utxo(addr) + // console.log(`result: ${JSON.stringify(result, null, 2)}`) - assert.property(result, "utxos") - assert.property(result, "legacyAddress") - assert.property(result, "cashAddress") - assert.property(result, "slpAddress") - assert.property(result, "scriptPubKey") - assert.property(result, "asm") + assert.property(result, "utxos") + assert.property(result, "legacyAddress") + assert.property(result, "cashAddress") + assert.property(result, "slpAddress") + assert.property(result, "scriptPubKey") + assert.property(result, "asm") - assert.isArray(result.utxos) + assert.isArray(result.utxos) - assert.property(result.utxos[0], "txid") - assert.property(result.utxos[0], "vout") - assert.property(result.utxos[0], "amount") - assert.property(result.utxos[0], "satoshis") - assert.property(result.utxos[0], "height") - assert.property(result.utxos[0], "confirmations") + assert.property(result.utxos[0], "txid") + assert.property(result.utxos[0], "vout") + assert.property(result.utxos[0], "amount") + assert.property(result.utxos[0], "satoshis") + assert.property(result.utxos[0], "height") + assert.property(result.utxos[0], "confirmations") + } catch (err) { + console.error("Error in test: ", err) + } }) it(`should POST utxo details for an array of addresses`, async () => { From 8facfd69ac60bb7a9b8a3408a127ebbb4dbdf913 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Thu, 13 Aug 2020 16:07:03 -0700 Subject: [PATCH 2/2] fix(ninsight): Fixing failing ninsight integration test --- src/ninsight.js | 2 +- test/integration/ninsight.js | 36 ++++++++++++++++-------------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/ninsight.js b/src/ninsight.js index 8c6427a..8611d71 100644 --- a/src/ninsight.js +++ b/src/ninsight.js @@ -69,7 +69,7 @@ class Ninsight { // Handle single address. if (typeof address === "string") { const response = await axios.post( - `${this.ninsightURL}/address/utxo/${address}`, + `${this.ninsightURL}/address/utxo`, { addresses: [address] }, diff --git a/test/integration/ninsight.js b/test/integration/ninsight.js index 726d677..b90213b 100644 --- a/test/integration/ninsight.js +++ b/test/integration/ninsight.js @@ -12,30 +12,26 @@ describe(`#Ninsight`, () => { describe(`#utxo`, () => { it(`should GET utxos for a single address`, async () => { - try { - const addr = "bitcoincash:qqh793x9au6ehvh7r2zflzguanlme760wuzehgzjh9" + const addr = "bitcoincash:qqh793x9au6ehvh7r2zflzguanlme760wuzehgzjh9" - const result = await bchjs.Ninsight.utxo(addr) - // console.log(`result: ${JSON.stringify(result, null, 2)}`) + const result = await bchjs.Ninsight.utxo(addr) + // console.log(`result: ${JSON.stringify(result, null, 2)}`) - assert.property(result, "utxos") - assert.property(result, "legacyAddress") - assert.property(result, "cashAddress") - assert.property(result, "slpAddress") - assert.property(result, "scriptPubKey") - assert.property(result, "asm") + assert.property(result[0], "utxos") + assert.property(result[0], "legacyAddress") + assert.property(result[0], "cashAddress") + assert.property(result[0], "slpAddress") + assert.property(result[0], "scriptPubKey") + assert.property(result[0], "asm") - assert.isArray(result.utxos) + assert.isArray(result[0].utxos) - assert.property(result.utxos[0], "txid") - assert.property(result.utxos[0], "vout") - assert.property(result.utxos[0], "amount") - assert.property(result.utxos[0], "satoshis") - assert.property(result.utxos[0], "height") - assert.property(result.utxos[0], "confirmations") - } catch (err) { - console.error("Error in test: ", err) - } + assert.property(result[0].utxos[0], "txid") + assert.property(result[0].utxos[0], "vout") + assert.property(result[0].utxos[0], "amount") + assert.property(result[0].utxos[0], "satoshis") + assert.property(result[0].utxos[0], "height") + assert.property(result[0].utxos[0], "confirmations") }) it(`should POST utxo details for an array of addresses`, async () => {