From 3a2f38bcf0723a5006736d73536045478cffa617 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 2 Nov 2020 14:27:31 -0800 Subject: [PATCH] fix(integration): Removed all non-integration tests from integration tests --- src/slp/tokentype1.js | 2 +- test/integration/blockbook.js | 38 ++++-------------- test/integration/blockchain.js | 64 ++++-------------------------- test/integration/openbazaar.js | 36 ----------------- test/integration/rawtransaction.js | 46 --------------------- test/integration/slp.js | 29 -------------- test/integration/test-free-tier.sh | 1 + test/integration/util.js | 15 ------- 8 files changed, 18 insertions(+), 213 deletions(-) diff --git a/src/slp/tokentype1.js b/src/slp/tokentype1.js index a1fd3fd..d6392f2 100644 --- a/src/slp/tokentype1.js +++ b/src/slp/tokentype1.js @@ -426,7 +426,7 @@ class TokenType1 { return slpSendObj } catch (err) { - console.log(err) + // console.log(err) throw err } } diff --git a/test/integration/blockbook.js b/test/integration/blockbook.js index 7b20a58..21f6d1b 100644 --- a/test/integration/blockbook.js +++ b/test/integration/blockbook.js @@ -18,6 +18,10 @@ util.inspect.defaultOptions = { } describe(`#Blockbook`, () => { + beforeEach(async () => { + if (process.env.IS_USING_FREE_TIER) await sleep(1000) + }) + describe(`#Balance`, () => { it(`should GET balance for a single address`, async () => { const addr = "bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf" @@ -67,21 +71,6 @@ describe(`#Blockbook`, () => { 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 = [] @@ -136,21 +125,6 @@ describe(`#Blockbook`, () => { ]) }) - 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 = [] @@ -168,3 +142,7 @@ describe(`#Blockbook`, () => { }) }) }) + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)) +} diff --git a/test/integration/blockchain.js b/test/integration/blockchain.js index 4ea3761..6c339d2 100644 --- a/test/integration/blockchain.js +++ b/test/integration/blockchain.js @@ -21,6 +21,10 @@ util.inspect.defaultOptions = { } describe(`#blockchain`, () => { + beforeEach(async () => { + if (process.env.IS_USING_FREE_TIER) await sleep(1000) + }) + describe(`#getBestBlockHash`, () => { it(`should GET best block hash`, async () => { const result = await bchjs.Blockchain.getBestBlockHash() @@ -85,20 +89,6 @@ describe(`#blockchain`, () => { ]) }) - it(`should throw an error for improper input`, async () => { - try { - const hash = 12345 - - await bchjs.Blockchain.getBlockHeader(hash) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - assert.include( - err.message, - `Input hash must be a string or array of strings` - ) - } - }) - it(`should throw error on array size rate limit`, async () => { try { const data = [] @@ -185,20 +175,6 @@ describe(`#blockchain`, () => { assert.include(err.error, `Transaction not in mempool`) } }) - - it(`should throw an error for improper single input`, async () => { - try { - const txid = 12345 - - await bchjs.Blockchain.getMempoolEntry(txid) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - assert.include( - err.message, - `Input must be a string or array of strings` - ) - } - }) }) describe(`#getTxOutProof`, () => { @@ -224,20 +200,6 @@ describe(`#blockchain`, () => { assert.isArray(result) assert.isString(result[0]) }) - - it(`should throw an error for improper single input`, async () => { - try { - const txid = 12345 - - await bchjs.Blockchain.getTxOutProof(txid) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - assert.include( - err.message, - `Input must be a string or array of strings` - ) - } - }) }) describe(`#verifyTxOutProof`, () => { @@ -269,20 +231,6 @@ describe(`#blockchain`, () => { ) }) - it(`should throw an error for improper single input`, async () => { - try { - const txid = 12345 - - await bchjs.Blockchain.verifyTxOutProof(txid) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - assert.include( - err.message, - `Input must be a string or array of strings` - ) - } - }) - it(`should throw error on array size rate limit`, async () => { try { const data = [] @@ -329,3 +277,7 @@ describe(`#blockchain`, () => { }) }) }) + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)) +} diff --git a/test/integration/openbazaar.js b/test/integration/openbazaar.js index 1cac45d..1bd149d 100644 --- a/test/integration/openbazaar.js +++ b/test/integration/openbazaar.js @@ -9,18 +9,6 @@ const bchjs = new BCHJS() describe(`#OpenBazaar`, () => { describe(`#Balance`, () => { - it(`should throw an error for improper input`, async () => { - try { - const addr = 12345 - - await bchjs.OpenBazaar.balance(addr) - // assert.equal(true, false, "Unexpected result!") - } catch (err) { - //console.log(`err: `, err) - assert.include(err.message, `Input address must be a string`) - } - }) - it(`should GET balance for a single address`, async () => { const addr = "bitcoincash:qqh793x9au6ehvh7r2zflzguanlme760wuzehgzjh9" @@ -45,18 +33,6 @@ describe(`#OpenBazaar`, () => { }) describe(`#utxo`, () => { - it(`should throw an error for improper input`, async () => { - try { - const addr = 12345 - - await bchjs.OpenBazaar.utxo(addr) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - //console.log(`err: `, err) - assert.include(err.message, `Input address must be a string`) - } - }) - it(`should GET utxos for a single address`, async () => { const addr = "bitcoincash:qqh793x9au6ehvh7r2zflzguanlme760wuzehgzjh9" @@ -76,18 +52,6 @@ describe(`#OpenBazaar`, () => { }) describe(`#tx`, () => { - it(`should throw an error for improper input`, async () => { - try { - const addr = 12345 - - await bchjs.OpenBazaar.tx(addr) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - //console.log(`err: `, err) - assert.include(err.message, `Input txid must be a string`) - } - }) - it(`should GET transactions for a single address`, async () => { const addr = "2b37bdb3b63dd0bca720437754a36671431a950e684b64c44ea910ea9d5297c7" diff --git a/test/integration/rawtransaction.js b/test/integration/rawtransaction.js index 3b79186..b6b4038 100644 --- a/test/integration/rawtransaction.js +++ b/test/integration/rawtransaction.js @@ -63,21 +63,6 @@ describe("#rawtransaction", () => { assert.isArray(result[0].vout) }) - it(`should throw an error for improper single input`, async () => { - try { - const addr = 12345 - - await bchjs.RawTransactions.decodeRawTransaction(addr) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - //console.log(`err: `, err) - assert.include( - err.message, - `Input must be a string or array of strings.` - ) - } - }) - it(`should throw error on array size rate limit`, async () => { try { const data = [] @@ -232,22 +217,6 @@ describe("#rawtransaction", () => { const result = await bchjs.RawTransactions.decodeScript(hexes) console.log(`result ${JSON.stringify(result, null, 2)}`) }) -*/ - /* - it(`should throw an error for improper single input`, async () => { - try { - const addr = 12345 - - await bchjs.RawTransactions.decodeRawTransaction(addr) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - //console.log(`err: `, err) - assert.include( - err.message, - `Input must be a string or array of strings.` - ) - } - }) */ }) @@ -292,21 +261,6 @@ describe("#rawtransaction", () => { } }) - it(`should throw an error for improper single input`, async () => { - try { - const addr = 12345 - - await bchjs.RawTransactions.sendRawTransaction(addr) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - //console.log(`err: `, err) - assert.include( - err.message, - `Input hex must be a string or array of strings` - ) - } - }) - it(`should throw error on array size rate limit`, async () => { try { const dataMock = diff --git a/test/integration/slp.js b/test/integration/slp.js index 685c509..cab94d3 100644 --- a/test/integration/slp.js +++ b/test/integration/slp.js @@ -466,22 +466,6 @@ describe(`#SLP`, () => { }) describe("#balancesForAddress", () => { - it(`should throw an error if input is not a string or array of strings`, async () => { - try { - const address = 1234 - - await bchjs.SLP.Utils.balancesForAddress(address) - - assert.equal(true, false, "Uh oh. Code path should not end here.") - } catch (err) { - //console.log(`Error: `, err) - assert.include( - err.message, - `Input address must be a string or array of strings` - ) - } - }) - it(`should fetch all balances for address: simpleledger:qzv3zz2trz0xgp6a96lu4m6vp2nkwag0kvyucjzqt9`, async () => { const balances = await bchjs.SLP.Utils.balancesForAddress( "simpleledger:qzv3zz2trz0xgp6a96lu4m6vp2nkwag0kvyucjzqt9" @@ -520,19 +504,6 @@ describe(`#SLP`, () => { }) describe("#hydrateUtxos", () => { - it("should throw an error if input is not an array", async () => { - try { - const utxos = 1234 - - await bchjs.SLP.Utils.hydrateUtxos(utxos) - - assert.equal(true, false, "Uh oh. Code path should not end here.") - } catch (err) { - // console.log(`Error: `, err) - assert.include(err.message, `Input must be an array.`) - } - }) - it("should hydrate UTXOs", async () => { const utxos = [ { diff --git a/test/integration/test-free-tier.sh b/test/integration/test-free-tier.sh index fa2aea2..2b9ed35 100755 --- a/test/integration/test-free-tier.sh +++ b/test/integration/test-free-tier.sh @@ -2,6 +2,7 @@ export RESTURL=https://free-main.fullstack.cash/v3/ #export RESTURL=http://localhost:3000/v3/ +export IS_USING_FREE_TIER=true cd test/integration/ mocha --timeout 30000 blockchain.js control.js electrumx.js ninsight.js openbazaar.js price.js rawtransaction.js slp.js util.js diff --git a/test/integration/util.js b/test/integration/util.js index 16de2f6..35831a8 100644 --- a/test/integration/util.js +++ b/test/integration/util.js @@ -75,21 +75,6 @@ describe(`#util`, () => { ]) }) - it(`should throw an error for improper single input`, async () => { - try { - const address = 15432 - - await bchjs.Util.validateAddress(address) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - //console.log(`err: `, err) - assert.include( - err.message, - `Input must be a string or array of strings.` - ) - } - }) - it(`should throw error on array size rate limit`, async () => { try { const dataMock = `bitcoincash:qp4k8fjtgunhdr7yq30ha4peuwupzan2vcnwrmpy0z`