From 056fcc274848e250cbcad334042265b2dfdf8c6a Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 18 Nov 2019 12:17:19 -0800 Subject: [PATCH] Fixed integration tests --- package.json | 2 +- test/integration/address.js | 12 ++++--- test/integration/other/README.md | 8 +++++ test/integration/transaction.js | 2 +- test/integration/util.js | 6 +--- test/integration/z9-rate-limits.js | 53 ------------------------------ 6 files changed, 19 insertions(+), 64 deletions(-) create mode 100644 test/integration/other/README.md delete mode 100644 test/integration/z9-rate-limits.js diff --git a/package.json b/package.json index ec29264d..d581950f 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "node-mocks-http": "^1.7.0", "nyc": "^14.1.1", "prettier": "^1.14.2", - "semantic-release": "^15.13.3", + "semantic-release": "^15.13.31", "sinon": "^4.5.0", "source-map-support": "^0.5.12", "ts-node": "^8.1.0", diff --git a/test/integration/address.js b/test/integration/address.js index 0c61d1ae..2536f17c 100644 --- a/test/integration/address.js +++ b/test/integration/address.js @@ -130,7 +130,8 @@ describe(`#address`, () => { "legacyAddress", "cashAddress", "scriptPubKey", - "slpAddress" + "slpAddress", + "asm" ]) assert.isArray(result.utxos) assert.hasAnyKeys(result.utxos[0], [ @@ -158,7 +159,8 @@ describe(`#address`, () => { "legacyAddress", "cashAddress", "scriptPubKey", - "slpAddress" + "slpAddress", + "asm" ]) assert.isArray(result[0].utxos) assert.hasAnyKeys(result[0].utxos[0], [ @@ -215,7 +217,8 @@ describe(`#address`, () => { "legacyAddress", "cashAddress", "scriptPubKey", - "slpAddress" + "slpAddress", + "asm" ]) assert.isArray(result.utxos) }) @@ -235,7 +238,8 @@ describe(`#address`, () => { "legacyAddress", "cashAddress", "scriptPubKey", - "slpAddress" + "slpAddress", + "asm" ]) assert.isArray(result[0].utxos) }) diff --git a/test/integration/other/README.md b/test/integration/other/README.md new file mode 100644 index 00000000..5c8068af --- /dev/null +++ b/test/integration/other/README.md @@ -0,0 +1,8 @@ +# Other Integration Tests + +This directory holds stand-alone integration tests that should not be part of +the integration test suite. + +An example of a test that fits this criteria are rate limit tests. Rate limit +tests are complex, require a solid internet connection, and can easily disrupt +other tests. For those reasons, it is better to run them on their own. diff --git a/test/integration/transaction.js b/test/integration/transaction.js index d36476f3..94b086b9 100644 --- a/test/integration/transaction.js +++ b/test/integration/transaction.js @@ -87,7 +87,7 @@ describe(`#Transaction`, () => { // console.log(`result: ${util.inspect(result)}`) assert.equal(false, false, "Unexpected result!") } catch (err) { - console.log(`err: ${util.inspect(err)}`) + // console.log(`err: ${util.inspect(err)}`) assert.hasAnyKeys(err, ["error"]) assert.include(err.error, "Array too large") diff --git a/test/integration/util.js b/test/integration/util.js index 964fe3b7..e2af5e2c 100644 --- a/test/integration/util.js +++ b/test/integration/util.js @@ -44,7 +44,7 @@ describe(`#util`, () => { assert.equal(result.isvalid, false) }) - it(`should return validate valid address`, async () => { + it(`should return a valid address`, async () => { const address = `bitcoincash:qp4k8fjtgunhdr7yq30ha4peuwupzan2vcnwrmpy0z` const result = await bitbox.Util.validateAddress(address) @@ -54,8 +54,6 @@ describe(`#util`, () => { "isvalid", "address", "scriptPubKey", - "ismine", - "iswatchonly", "isscript" ]) assert.equal(result.isvalid, true) @@ -75,8 +73,6 @@ describe(`#util`, () => { "isvalid", "address", "scriptPubKey", - "ismine", - "iswatchonly", "isscript" ]) }) diff --git a/test/integration/z9-rate-limits.js b/test/integration/z9-rate-limits.js deleted file mode 100644 index 6e9c4653..00000000 --- a/test/integration/z9-rate-limits.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - This test file should be run last as it will trigger the rate limits in - rest.bitcoin.com and no more calls to rest will be possible for about 1 minute - after this test is run. -*/ - -const chai = require("chai") -const assert = chai.assert - -const BITBOX = require("../../lib/BITBOX").BITBOX -let bitbox = new BITBOX() - -if (process.env.SERVER === "local") - bitbox = new BITBOX({ restURL: "http://localhost:3000/v2/" }) -if (process.env.SERVER === "stage") - bitbox = new BITBOX({ restURL: "https://rest.btctest.net/v2/" }) - -// Inspect utility used for debugging. -const util = require("util") -util.inspect.defaultOptions = { - showHidden: true, - colors: true, - depth: 3 -} - -describe("#rate-limits", () => { - it("should throw an error when RPM rate limits are triggered", async () => { - try { - const promises = [] - for (let i = 0; i < 300; i++) { - const promise = bitbox.Control.getInfo() - promises.push(promise) - } - - const temp = await Promise.all(promises) - - // console.log(`temp: ${util.inspect(temp)}`) - assert.equal(true, false, "Unexpected result!") - } catch (err) { - // Expected error response - if (err.error) { - assert.hasAnyKeys(err, ["error"]) - assert.include(err.error, "Too many requests") - - // Handle other types of error response. - } else { - console.log(`Unexpected error:`) - // console.log(`err: ${util.inspect(err)}`) - assert.equal(true, false, "Unexpected error") - } - } - }) -})