From d6ae6ffb6bd69905f31c04399263402ec7d38643 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Sun, 6 Dec 2020 19:39:23 -0800 Subject: [PATCH] fix(tests): Cleaning up integration tests --- test/integration/bchn/slp.js | 4 +- test/integration/slp.js | 94 ++++++++++++++++++++++- test/integration/test-bchn-integration.sh | 4 +- 3 files changed, 97 insertions(+), 5 deletions(-) diff --git a/test/integration/bchn/slp.js b/test/integration/bchn/slp.js index ee73195..fee74b9 100644 --- a/test/integration/bchn/slp.js +++ b/test/integration/bchn/slp.js @@ -553,11 +553,11 @@ describe(`#SLP`, () => { ] const data = await bchjs.SLP.Utils.tokenUtxoDetails(utxos) - console.log(`data: ${JSON.stringify(data, null, 2)}`) + // console.log(`data: ${JSON.stringify(data, null, 2)}`) // Malformed SLP tx assert.equal(data[0].tx_hash, utxos[0].tx_hash) - assert.equal(data[0].isValid, null) + assert.equal(data[0].isValid, false) // Normal TX (non-SLP) assert.equal(data[1].tx_hash, utxos[1].tx_hash) diff --git a/test/integration/slp.js b/test/integration/slp.js index 30413a0..d327858 100644 --- a/test/integration/slp.js +++ b/test/integration/slp.js @@ -463,6 +463,98 @@ describe(`#SLP`, () => { assert.equal(data[0].isValid, false) }) + + it("should handle a range of UTXO types", async () => { + const utxos = [ + // Malformed SLP tx + { + note: "Malformed SLP tx", + tx_hash: + "f7e5199ef6669ad4d078093b3ad56e355b6ab84567e59ad0f08a5ad0244f783a", + tx_pos: 1, + value: 546 + }, + // Normal TX (non-SLP) + { + note: "Normal TX (non-SLP)", + tx_hash: + "01cdaec2f8b311fc2d6ecc930247bd45fa696dc204ab684596e281fe1b06c1f0", + tx_pos: 0, + value: 400000 + }, + // Valid PSF SLP tx + { + note: "Valid PSF SLP tx", + tx_hash: + "daf4d8b8045e7a90b7af81bfe2370178f687da0e545511bce1c9ae539eba5ffd", + tx_pos: 1, + value: 546 + }, + // Valid SLP token not in whitelist + { + note: "Valid SLP token not in whitelist", + tx_hash: + "3a4b628cbcc183ab376d44ce5252325f042268307ffa4a53443e92b6d24fb488", + tx_pos: 1, + value: 546 + }, + // Token send on BCHN network. + { + note: "Token send on BCHN network", + tx_hash: + "402c663379d9699b6e2dd38737061e5888c5a49fca77c97ab98e79e08959e019", + tx_pos: 1, + value: 546 + }, + // Token send on ABC network. + { + note: "Token send on ABC network", + tx_hash: + "336bfe2168aac4c3303508a9e8548a0d33797a83b85b76a12d845c8d6674f79d", + tx_pos: 1, + value: 546 + }, + // Known invalid SLP token send of PSF tokens. + { + note: "Known invalid SLP token send of PSF tokens", + tx_hash: + "2bf691ad3679d928fef880b8a45b93b233f8fa0d0a92cf792313dbe77b1deb74", + tx_pos: 1, + value: 546 + } + ] + + const data = await bchjs.SLP.Utils.tokenUtxoDetails(utxos) + // console.log(`data: ${JSON.stringify(data, null, 2)}`) + + // Malformed SLP tx + assert.equal(data[0].tx_hash, utxos[0].tx_hash) + assert.equal(data[0].isValid, false) + + // Normal TX (non-SLP) + assert.equal(data[1].tx_hash, utxos[1].tx_hash) + assert.equal(data[1].isValid, false) + + // Valid PSF SLP tx + assert.equal(data[2].tx_hash, utxos[2].tx_hash) + assert.equal(data[2].isValid, true) + + // Valid SLP token not in whitelist + assert.equal(data[3].tx_hash, utxos[3].tx_hash) + assert.equal(data[3].isValid, true) + + // Token send on BCHN network + assert.equal(data[4].tx_hash, utxos[4].tx_hash) + assert.equal(data[4].isValid, null) + + // Token send on ABC network + assert.equal(data[5].tx_hash, utxos[5].tx_hash) + assert.equal(data[5].isValid, true) + + // Known invalid SLP token send of PSF tokens + assert.equal(data[6].tx_hash, utxos[6].tx_hash) + assert.equal(data[6].isValid, false) + }) }) describe("#balancesForAddress", () => { @@ -652,7 +744,7 @@ describe(`#SLP`, () => { "f7e5199ef6669ad4d078093b3ad56e355b6ab84567e59ad0f08a5ad0244f783a" const result = await bchjs.SLP.Utils.validateTxid3(txid) - console.log(`result: ${JSON.stringify(result, null, 2)}`) + // console.log(`result: ${JSON.stringify(result, null, 2)}`) assert.isArray(result) diff --git a/test/integration/test-bchn-integration.sh b/test/integration/test-bchn-integration.sh index da7a11b..1032554 100755 --- a/test/integration/test-bchn-integration.sh +++ b/test/integration/test-bchn-integration.sh @@ -5,5 +5,5 @@ #export IS_USING_FREE_TIER=true cd test/integration/bchn/ -#mocha --timeout 30000 blockchain.js control.js encryption.js electrumx.js ninsight.js openbazaar.js price.js rawtransaction.js slp.js util.js -mocha --timeout 30000 slp.js +mocha --timeout 30000 blockchain.js control.js encryption.js electrumx.js ninsight.js openbazaar.js price.js rawtransaction.js slp.js util.js +#mocha --timeout 30000 slp.js