From 360d56e283a36a218feb5d681f255b483378cd92 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Sun, 8 Nov 2020 14:05:10 -0800 Subject: [PATCH] fix(network): Updates for fork --- package.json | 8 +- test/integration/bchn/blockbook.js | 170 --------------------- test/integration/test-free-tier-bchn.sh | 6 +- test/integration/testnet/blockbook.js | 2 +- test/integration/testnet/blockchain.js | 2 +- test/integration/testnet/control.js | 2 +- test/integration/testnet/electrumx.js | 2 +- test/integration/testnet/rawtransaction.js | 2 +- test/integration/testnet/slp.js | 2 +- test/integration/testnet/util.js | 2 +- 10 files changed, 15 insertions(+), 183 deletions(-) delete mode 100644 test/integration/bchn/blockbook.js diff --git a/package.json b/package.json index dac3a34..09fb823 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,16 @@ "main": "src/bch-js", "scripts": { "test": "nyc mocha --timeout 30000 test/unit/", - "test:integration": "IS_USING_FREE_TIER=true mocha --timeout 30000 test/integration/", + "test:integration": "bash test/integration/test-free-tier-bchn.sh", + "test:integration:abc": "RESTURL=https://abc.fullstack.cash/v3/ IS_USING_FREE_TIER=true mocha --timeout 30000 test/integration/", "test:integration:testnet": "IS_USING_FREE_TIER=true mocha --timeout 30000 test/integration/testnet/", "test:integration:local": "RESTURL=http://localhost:3000/v3/ mocha --timeout 30000 test/integration", + "test:integration:local:bchn": "RESTURL=http://localhost:3000/v3/ bash test/integration/test-free-tier-bchn.sh", "test:integration:testnet:local": "RESTURL=http://localhost:4000/v3/ mocha --timeout 30000 test/integration/testnet", "test:integration:free": "bash test/integration/test-free-tier.sh", - "test:integration:free:bchn": "bash test/integration/test-free-tier-bchn.sh", + "test:integration:free:bchn": "IS_USING_FREE_TIER=true bash test/integration/test-free-tier-bchn.sh", "test:integration:free:testnet": "bash test/integration/testnet/test-free-tier.sh", - "test:temp": "mocha --timeout 30000 -g '#hydrateUtxos' test/integration/", + "test:temp": "mocha --timeout 30000 -g '#Encryption' test/integration/", "test:integration:api": "RESTURL=https://api.fullstack.cash/v3/ mocha --timeout 30000 test/integration", "coverage": "nyc report --reporter=text-lcov | coveralls", "coverage:report": "nyc --reporter=html mocha --timeout 25000 test/unit/", diff --git a/test/integration/bchn/blockbook.js b/test/integration/bchn/blockbook.js deleted file mode 100644 index 904ec83..0000000 --- a/test/integration/bchn/blockbook.js +++ /dev/null @@ -1,170 +0,0 @@ -/* - Integration tests for the Blockbook library. - -*/ - -const chai = require("chai") -const assert = chai.assert -const BCHJS = require("../../../src/bch-js") -const bchjs = new BCHJS() -//const axios = require("axios") - -// Inspect utility used for debugging. -const util = require("util") -util.inspect.defaultOptions = { - showHidden: true, - colors: true, - depth: 3 -} - -describe(`#Blockbook`, () => { - describe(`#Balance`, () => { - it(`should GET balance for a single address`, async () => { - const addr = "bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf" - - const result = await bchjs.Blockbook.balance(addr) - //console.log(`result: ${util.inspect(result)}`) - - assert.hasAnyKeys(result, [ - "page", - "totalPages", - "itemsOnPage", - "address", - "balance", - "totalReceived", - "totalSent", - "unconfirmedBalance", - "unconfirmedTxs", - "txs", - "txids" - ]) - assert.isArray(result.txids) - }) - - it(`should POST request balances for an array of addresses`, async () => { - const addr = [ - "bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf", - "bitcoincash:qpdh9s677ya8tnx7zdhfrn8qfyvy22wj4qa7nwqa5v" - ] - - const result = await bchjs.Blockbook.balance(addr) - //console.log(`result: ${util.inspect(result)}`) - - assert.isArray(result) - assert.hasAnyKeys(result[0], [ - "page", - "totalPages", - "itemsOnPage", - "address", - "balance", - "totalReceived", - "totalSent", - "unconfirmedBalance", - "unconfirmedTxs", - "txs", - "txids" - ]) - assert.isArray(result[0].txids) - }) - - it(`should throw an error for improper input`, async () => { - try { - const addr = 12345 - - await bchjs.Blockbook.balance(addr) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - //console.log(`err: `, err) - assert.include( - err.message, - `Input address must be a string or array of strings` - ) - } - }) - - it(`should throw error on array size rate limit`, async () => { - try { - const addr = [] - for (let i = 0; i < 25; i++) - addr.push("bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf") - - const result = await bchjs.Blockbook.balance(addr) - - console.log(`result: ${util.inspect(result)}`) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - assert.hasAnyKeys(err, ["error"]) - assert.include(err.error, "Array too large") - } - }) - }) - - describe(`#utxo`, () => { - it(`should GET utxos for a single address`, async () => { - const addr = "bitcoincash:qp3sn6vlwz28ntmf3wmyra7jqttfx7z6zgtkygjhc7" - - const result = await bchjs.Blockbook.utxo(addr) - // console.log(`result: ${JSON.stringify(result, null, 2)}`) - - assert.isArray(result) - assert.hasAnyKeys(result[0], [ - "txid", - "vout", - "value", - "height", - "confirmations" - ]) - }) - - it(`should POST utxo details for an array of addresses`, async () => { - const addr = [ - "bitcoincash:qp3sn6vlwz28ntmf3wmyra7jqttfx7z6zgtkygjhc7", - "bitcoincash:qz0us0z6ucpqt07jgpad0shgh7xmwxyr3ynlcsq0wr" - ] - - const result = await bchjs.Blockbook.utxo(addr) - //console.log(`result: ${JSON.stringify(result, null, 2)}`) - - assert.isArray(result) - assert.isArray(result[0]) - assert.hasAnyKeys(result[0][0], [ - "txid", - "vout", - "value", - "height", - "confirmations" - ]) - }) - - it(`should throw an error for improper input`, async () => { - try { - const addr = 12345 - - await bchjs.Blockbook.utxo(addr) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - //console.log(`err: `, err) - assert.include( - err.message, - `Input address must be a string or array of strings` - ) - } - }) - - it(`should throw error on array size rate limit`, async () => { - try { - const addr = [] - for (let i = 0; i < 25; i++) - addr.push("bitcoincash:qz0us0z6ucpqt07jgpad0shgh7xmwxyr3ynlcsq0wr") - - const result = await bchjs.Blockbook.utxo(addr) - //console.log(`result: ${util.inspect(result)}`) - - assert.equal(true, false, "Unexpected result!") - } catch (err) { - assert.hasAnyKeys(err, ["error"]) - assert.include(err.error, "Array too large") - } - }) - }) -}) diff --git a/test/integration/test-free-tier-bchn.sh b/test/integration/test-free-tier-bchn.sh index f0a1cb9..f2464c7 100755 --- a/test/integration/test-free-tier-bchn.sh +++ b/test/integration/test-free-tier-bchn.sh @@ -1,8 +1,8 @@ #!/bin/bash -export RESTURL=https://bchn-free-main.fullstack.cash/v3/ +#export RESTURL=https://bchn.fullstack.cash/v3/ #export RESTURL=http://localhost:3000/v3/ -export IS_USING_FREE_TIER=true +#export IS_USING_FREE_TIER=true cd test/integration/bchn/ -mocha --timeout 30000 blockchain.js control.js electrumx.js ninsight.js openbazaar.js price.js rawtransaction.js slp.js util.js +mocha --timeout 30000 blockchain.js control.js encryption.js electrumx.js ninsight.js openbazaar.js price.js rawtransaction.js slp.js util.js diff --git a/test/integration/testnet/blockbook.js b/test/integration/testnet/blockbook.js index 18d7c31..d278d5d 100644 --- a/test/integration/testnet/blockbook.js +++ b/test/integration/testnet/blockbook.js @@ -8,7 +8,7 @@ const assert = chai.assert const RESTURL = process.env.RESTURL ? process.env.RESTURL - : `https://tapi.fullstack.cash/v3/` + : `https://testnet3.fullstack.cash/v3/` // if (process.env.RESTURL) RESTURL = process.env.RESTURL const BCHJS = require("../../../src/bch-js") diff --git a/test/integration/testnet/blockchain.js b/test/integration/testnet/blockchain.js index 3d777f8..859c3ac 100644 --- a/test/integration/testnet/blockchain.js +++ b/test/integration/testnet/blockchain.js @@ -12,7 +12,7 @@ const assert = chai.assert const RESTURL = process.env.RESTURL ? process.env.RESTURL - : "https://tapi.fullstack.cash/v3/" + : "https://testnet3.fullstack.cash/v3/" // if (process.env.RESTURL) RESTURL = process.env.RESTURL const BCHJS = require("../../../src/bch-js") diff --git a/test/integration/testnet/control.js b/test/integration/testnet/control.js index 863cafd..102e0b0 100644 --- a/test/integration/testnet/control.js +++ b/test/integration/testnet/control.js @@ -7,7 +7,7 @@ const assert = chai.assert const RESTURL = process.env.RESTURL ? process.env.RESTURL - : `https://tapi.fullstack.cash/v3/` + : `https://testnet3.fullstack.cash/v3/` const BCHJS = require("../../../src/bch-js") const bchjs = new BCHJS({ restURL: RESTURL, apiToken: process.env.BCHJSTOKEN }) diff --git a/test/integration/testnet/electrumx.js b/test/integration/testnet/electrumx.js index c880ab4..f4898c0 100644 --- a/test/integration/testnet/electrumx.js +++ b/test/integration/testnet/electrumx.js @@ -4,7 +4,7 @@ const sinon = require("sinon") const RESTURL = process.env.RESTURL ? process.env.RESTURL - : `https://tapi.fullstack.cash/v3/` + : `https://testnet3.fullstack.cash/v3/` const BCHJS = require("../../../src/bch-js") const bchjs = new BCHJS({ restURL: RESTURL, apiToken: process.env.BCHJSTOKEN }) diff --git a/test/integration/testnet/rawtransaction.js b/test/integration/testnet/rawtransaction.js index d2fa1fb..a79d009 100644 --- a/test/integration/testnet/rawtransaction.js +++ b/test/integration/testnet/rawtransaction.js @@ -10,7 +10,7 @@ const assert = chai.assert const RESTURL = process.env.RESTURL ? process.env.RESTURL - : `https://tapi.fullstack.cash/v3/` + : `https://testnet3.fullstack.cash/v3/` // if (process.env.RESTURL) RESTURL = process.env.RESTURL const BCHJS = require("../../../src/bch-js") diff --git a/test/integration/testnet/slp.js b/test/integration/testnet/slp.js index 5ceb546..d3d6c57 100644 --- a/test/integration/testnet/slp.js +++ b/test/integration/testnet/slp.js @@ -7,7 +7,7 @@ const assert = chai.assert const RESTURL = process.env.RESTURL ? process.env.RESTURL - : `https://tapi.fullstack.cash/v3/` + : `https://testnet3.fullstack.cash/v3/` // if (process.env.RESTURL) RESTURL = process.env.RESTURL const BCHJS = require("../../../src/bch-js") diff --git a/test/integration/testnet/util.js b/test/integration/testnet/util.js index f30f076..0a5c2e7 100644 --- a/test/integration/testnet/util.js +++ b/test/integration/testnet/util.js @@ -8,7 +8,7 @@ const assert = chai.assert const RESTURL = process.env.RESTURL ? process.env.RESTURL - : `https://tapi.fullstack.cash/v3/` + : `https://testnet3.fullstack.cash/v3/` // if (process.env.RESTURL) RESTURL = process.env.RESTURL const BCHJS = require("../../../src/bch-js")