From 1012f4c1bf42a46b6c4dbb50ef43127c50856c9e Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Sat, 2 Jan 2021 16:39:44 -0800 Subject: [PATCH] Wrapping up linting --- test/integration/chains/testnet/electrumx.js | 6 +- test/integration/chains/testnet/slp.js | 17 +- test/integration/electrumx.js | 19 +- test/unit/address.js | 167 +++--- test/unit/blockchain.js | 60 +- test/unit/control.js | 8 +- test/unit/fixtures/ipfs-mock.js | 2 +- test/unit/fixtures/slp/mock-utils.js | 5 +- test/unit/generating.js | 4 +- test/unit/hdnode.js | 82 +-- test/unit/ipfs.js | 8 +- test/unit/mining.js | 16 +- test/unit/raw-tranactions.js | 18 +- test/unit/slp-tokentype1.js | 546 +++++++++---------- test/unit/slp-utils.js | 4 +- test/unit/transaction-builder.js | 105 ++-- test/unit/util.js | 4 +- 17 files changed, 535 insertions(+), 536 deletions(-) diff --git a/test/integration/chains/testnet/electrumx.js b/test/integration/chains/testnet/electrumx.js index acdaeec..881f2b4 100644 --- a/test/integration/chains/testnet/electrumx.js +++ b/test/integration/chains/testnet/electrumx.js @@ -1,6 +1,7 @@ const chai = require('chai') const assert = chai.assert const sinon = require('sinon') +const util = require('util') const RESTURL = process.env.RESTURL ? process.env.RESTURL @@ -69,8 +70,9 @@ describe('#ElectrumX', () => { const addr = [] for (let i = 0; i < 25; i++) { addr.push('bchtest:qrvn2n228aa39xupcw9jw0d3fj8axxky656e4j62z2') } - const result = await bchjs.Electrumx.utxo(addr) + // const result = await bchjs.Electrumx.utxo(addr) // console.log(`result: ${util.inspect(result)}`) + await bchjs.Electrumx.utxo(addr) assert.equal(true, false, 'Unexpected result!') } catch (err) { @@ -333,7 +335,7 @@ describe('#ElectrumX', () => { await bchjs.Electrumx.txData(txids) - console.log(`result: ${util.inspect(result)}`) + // console.log(`result: ${util.inspect(result)}`) assert.equal(true, false, 'Unexpected result!') } catch (err) { assert.hasAnyKeys(err, ['error']) diff --git a/test/integration/chains/testnet/slp.js b/test/integration/chains/testnet/slp.js index 330c259..7428d7a 100644 --- a/test/integration/chains/testnet/slp.js +++ b/test/integration/chains/testnet/slp.js @@ -30,7 +30,8 @@ describe('#SLP', () => { describe('#util', () => { it('should get information on the Oasis token', async () => { - const tokenId = 'a371e9934c7695d08a5eb7f31d3bceb4f3644860cc67520cda1e149423b9ec39' + const tokenId = + 'a371e9934c7695d08a5eb7f31d3bceb4f3644860cc67520cda1e149423b9ec39' const result = await bchjs.SLP.Utils.list(tokenId) // console.log(`result: ${JSON.stringify(result, null, 2)}`) @@ -74,13 +75,6 @@ describe('#SLP', () => { describe('#balancesForAddress', () => { it('should fetch all balances for address: slptest:qz0kc67pm4emjyr3gaaa2wstdaykg9m4yqwlzpj3w9', async () => { - // Mock the call to rest.bitcoin.com - if (process.env.TEST === 'unit') { - sandbox - .stub(axios, 'get') - .resolves({ data: mockData.balancesForAddress }) - } - const balances = await bchjs.SLP.Utils.balancesForAddress( 'slptest:qz0kc67pm4emjyr3gaaa2wstdaykg9m4yqwlzpj3w9' ) @@ -102,13 +96,6 @@ describe('#SLP', () => { 'slptest:qr5uy4h8ysyhwkp9s245scckdnc7teyjqc5ft2z43h' ] - // Mock the call to rest.bitcoin.com - if (process.env.TEST === 'unit') { - sandbox - .stub(axios, 'post') - .resolves({ data: mockData.balancesForAddresses }) - } - const balances = await bchjs.SLP.Utils.balancesForAddress(addresses) // console.log(`balances: ${JSON.stringify(balances, null, 2)}`) diff --git a/test/integration/electrumx.js b/test/integration/electrumx.js index cdd5c53..24e9d88 100644 --- a/test/integration/electrumx.js +++ b/test/integration/electrumx.js @@ -65,9 +65,10 @@ describe('#ElectrumX', () => { const addr = [] for (let i = 0; i < 25; i++) { addr.push('bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf') } - const result = await bchjs.Electrumx.utxo(addr) + // const result = await bchjs.Electrumx.utxo(addr) + await bchjs.Electrumx.utxo(addr) - console.log(`result: ${util.inspect(result)}`) + // console.log(`result: ${util.inspect(result)}`) assert.equal(true, false, 'Unexpected result!') } catch (err) { assert.hasAnyKeys(err, ['error']) @@ -117,9 +118,11 @@ describe('#ElectrumX', () => { const addr = [] for (let i = 0; i < 25; i++) { addr.push('bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf') } - const result = await bchjs.Electrumx.balance(addr) + // const result = await bchjs.Electrumx.balance(addr) + // console.log(`result: ${util.inspect(result)}`) + + await bchjs.Electrumx.balance(addr) - console.log(`result: ${util.inspect(result)}`) assert.equal(true, false, 'Unexpected result!') } catch (err) { assert.hasAnyKeys(err, ['error']) @@ -171,9 +174,11 @@ describe('#ElectrumX', () => { const addr = [] for (let i = 0; i < 25; i++) { addr.push('bitcoincash:qrehqueqhw629p6e57994436w730t4rzasnly00ht0') } - const result = await bchjs.Electrumx.transactions(addr) + // const result = await bchjs.Electrumx.transactions(addr) + // console.log(`result: ${util.inspect(result)}`) + + await bchjs.Electrumx.transactions(addr) - console.log(`result: ${util.inspect(result)}`) assert.equal(true, false, 'Unexpected result!') } catch (err) { assert.hasAnyKeys(err, ['error']) @@ -329,7 +334,7 @@ describe('#ElectrumX', () => { await bchjs.Electrumx.txData(txids) - console.log(`result: ${util.inspect(result)}`) + // console.log(`result: ${util.inspect(result)}`) assert.equal(true, false, 'Unexpected result!') } catch (err) { assert.hasAnyKeys(err, ['error']) diff --git a/test/unit/address.js b/test/unit/address.js index 85a8a6c..d2e5524 100644 --- a/test/unit/address.js +++ b/test/unit/address.js @@ -21,23 +21,23 @@ const LEGACY_ADDRESSES = flatten([ fixtures.legacyTestnetP2PKH ]) -const mainnet_xpubs = [] +const mainnetXpubs = [] fixtures.mainnetXPub.forEach((f, i) => { - mainnet_xpubs.push(f.xpub) + mainnetXpubs.push(f.xpub) }) const MAINNET_ADDRESSES = flatten([ - mainnet_xpubs, + mainnetXpubs, fixtures.legacyMainnetP2PKH, fixtures.legacyMainnetP2SH, fixtures.cashaddrMainnetP2PKH ]) -const testnet_xpubs = [] +const testnetXpubs = [] fixtures.testnetXPub.forEach((f, i) => { - testnet_xpubs.push(f.xpub) + testnetXpubs.push(f.xpub) }) const TESTNET_ADDRESSES = flatten([ - testnet_xpubs, + testnetXpubs, fixtures.legacyTestnetP2PKH, fixtures.cashaddrTestnetP2PKH ]) @@ -87,7 +87,7 @@ describe('#address.js', () => { describe('#addressConversion', () => { describe('#toLegacyAddress', () => { it('should translate legacy address format to itself correctly', () => { - assert.deepEqual( + assert.deepStrictEqual( LEGACY_ADDRESSES.map(address => bchjs.Address.toLegacyAddress(address) ), @@ -96,7 +96,7 @@ describe('#address.js', () => { }) it('should convert cashaddr address to legacy base58Check', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES.map(address => bchjs.Address.toLegacyAddress(address) ), @@ -105,7 +105,7 @@ describe('#address.js', () => { }) it('should convert cashaddr regtest address to legacy base58Check', () => { - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES.map(address => bchjs.Address.toLegacyAddress(address) ), @@ -127,7 +127,7 @@ describe('#address.js', () => { describe('#toCashAddress', () => { it('should convert legacy base58Check address to cashaddr', () => { - assert.deepEqual( + assert.deepStrictEqual( LEGACY_ADDRESSES.map(address => bchjs.Address.toCashAddress(address, true) ), @@ -136,7 +136,7 @@ describe('#address.js', () => { }) it('should convert legacy base58Check address to regtest cashaddr', () => { - assert.deepEqual( + assert.deepStrictEqual( fixtures.legacyTestnetP2PKH.map(address => bchjs.Address.toCashAddress(address, true, true) ), @@ -145,7 +145,7 @@ describe('#address.js', () => { }) it('should translate cashaddr address format to itself correctly', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES.map(address => bchjs.Address.toCashAddress(address, true) ), @@ -154,7 +154,7 @@ describe('#address.js', () => { }) it('should translate regtest cashaddr address format to itself correctly', () => { - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES.map(address => bchjs.Address.toCashAddress(address, true, true) ), @@ -163,7 +163,7 @@ describe('#address.js', () => { }) it('should translate no-prefix cashaddr address format to itself correctly', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.toCashAddress(address, true) ), @@ -172,7 +172,7 @@ describe('#address.js', () => { }) it('should translate no-prefix regtest cashaddr address format to itself correctly', () => { - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.toCashAddress(address, true, true) ), @@ -183,14 +183,14 @@ describe('#address.js', () => { it('should translate cashaddr address format to itself of no-prefix correctly', () => { CASHADDR_ADDRESSES.forEach(address => { const noPrefix = bchjs.Address.toCashAddress(address, false) - assert.equal(address.split(':')[1], noPrefix) + assert.strictEqual(address.split(':')[1], noPrefix) }) }) it('should translate regtest cashaddr address format to itself of no-prefix correctly', () => { REGTEST_ADDRESSES.forEach(address => { const noPrefix = bchjs.Address.toCashAddress(address, false, true) - assert.equal(address.split(':')[1], noPrefix) + assert.strictEqual(address.split(':')[1], noPrefix) }) }) @@ -208,21 +208,21 @@ describe('#address.js', () => { describe('#toHash160', () => { it('should convert legacy base58check address to hash160', () => { - assert.deepEqual( + assert.deepStrictEqual( LEGACY_ADDRESSES.map(address => bchjs.Address.toHash160(address)), HASH160_HASHES ) }) it('should convert cashaddr address to hash160', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES.map(address => bchjs.Address.toHash160(address)), HASH160_HASHES ) }) it('should convert regtest cashaddr address to hash160', () => { - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES.map(address => bchjs.Address.toHash160(address)), fixtures.hash160TestnetP2PKH ) @@ -242,7 +242,7 @@ describe('#address.js', () => { describe('#fromHash160', () => { it('should convert hash160 to mainnet P2PKH legacy base58check address', () => { - assert.deepEqual( + assert.deepStrictEqual( fixtures.hash160MainnetP2PKH.map(hash160 => bchjs.Address.hash160ToLegacy(hash160) ), @@ -251,7 +251,7 @@ describe('#address.js', () => { }) it('should convert hash160 to mainnet P2SH legacy base58check address', () => { - assert.deepEqual( + assert.deepStrictEqual( fixtures.hash160MainnetP2SH.map(hash160 => bchjs.Address.hash160ToLegacy( hash160, @@ -263,7 +263,7 @@ describe('#address.js', () => { }) it('should convert hash160 to testnet P2PKH legacy base58check address', () => { - assert.deepEqual( + assert.deepStrictEqual( fixtures.hash160TestnetP2PKH.map(hash160 => bchjs.Address.hash160ToLegacy( hash160, @@ -275,7 +275,7 @@ describe('#address.js', () => { }) it('should convert hash160 to mainnet P2PKH cash address', () => { - assert.deepEqual( + assert.deepStrictEqual( fixtures.hash160MainnetP2PKH.map(hash160 => bchjs.Address.hash160ToCash(hash160) ), @@ -284,7 +284,7 @@ describe('#address.js', () => { }) it('should convert hash160 to mainnet P2SH cash address', () => { - assert.deepEqual( + assert.deepStrictEqual( fixtures.hash160MainnetP2SH.map(hash160 => bchjs.Address.hash160ToCash( hash160, @@ -296,7 +296,7 @@ describe('#address.js', () => { }) it('should convert hash160 to testnet P2PKH cash address', () => { - assert.deepEqual( + assert.deepStrictEqual( fixtures.hash160TestnetP2PKH.map(hash160 => bchjs.Address.hash160ToCash( hash160, @@ -308,7 +308,7 @@ describe('#address.js', () => { }) it('should convert hash160 to regtest P2PKH cash address', () => { - assert.deepEqual( + assert.deepStrictEqual( fixtures.hash160TestnetP2PKH.map(hash160 => bchjs.Address.hash160ToCash( hash160, @@ -345,7 +345,7 @@ describe('#address.js', () => { LEGACY_ADDRESSES.forEach(address => { it(`should detect ${address} is a legacy base58Check address`, () => { const isBase58Check = bchjs.Address.isLegacyAddress(address) - assert.equal(isBase58Check, true) + assert.strictEqual(isBase58Check, true) }) }) }) @@ -353,14 +353,14 @@ describe('#address.js', () => { CASHADDR_ADDRESSES.forEach(address => { it(`should detect ${address} is not a legacy address`, () => { const isBase58Check = bchjs.Address.isLegacyAddress(address) - assert.equal(isBase58Check, false) + assert.strictEqual(isBase58Check, false) }) }) REGTEST_ADDRESSES.forEach(address => { it(`should detect ${address} is not a legacy address`, () => { const isBase58Check = bchjs.Address.isLegacyAddress(address) - assert.equal(isBase58Check, false) + assert.strictEqual(isBase58Check, false) }) }) }) @@ -382,14 +382,14 @@ describe('#address.js', () => { CASHADDR_ADDRESSES.forEach(address => { it(`should detect ${address} is a cashaddr address`, () => { const isCashaddr = bchjs.Address.isCashAddress(address) - assert.equal(isCashaddr, true) + assert.strictEqual(isCashaddr, true) }) }) REGTEST_ADDRESSES.forEach(address => { it(`should detect ${address} is a cashaddr address`, () => { const isCashaddr = bchjs.Address.isCashAddress(address) - assert.equal(isCashaddr, true) + assert.strictEqual(isCashaddr, true) }) }) }) @@ -398,7 +398,7 @@ describe('#address.js', () => { LEGACY_ADDRESSES.forEach(address => { it(`should detect ${address} is not a cashaddr address`, () => { const isCashaddr = bchjs.Address.isCashAddress(address) - assert.equal(isCashaddr, false) + assert.strictEqual(isCashaddr, false) }) }) }) @@ -419,7 +419,7 @@ describe('#address.js', () => { HASH160_HASHES.forEach(address => { it(`should detect ${address} is a hash160 hash`, () => { const isHash160 = bchjs.Address.isHash160(address) - assert.equal(isHash160, true) + assert.strictEqual(isHash160, true) }) }) }) @@ -427,21 +427,21 @@ describe('#address.js', () => { LEGACY_ADDRESSES.forEach(address => { it(`should detect ${address} is not a hash160 hash`, () => { const isHash160 = bchjs.Address.isHash160(address) - assert.equal(isHash160, false) + assert.strictEqual(isHash160, false) }) }) CASHADDR_ADDRESSES.forEach(address => { it(`should detect ${address} is not a hash160 hash`, () => { const isHash160 = bchjs.Address.isHash160(address) - assert.equal(isHash160, false) + assert.strictEqual(isHash160, false) }) }) REGTEST_ADDRESSES.forEach(address => { it(`should detect ${address} is not a legacy address`, () => { const isHash160 = bchjs.Address.isHash160(address) - assert.equal(isHash160, false) + assert.strictEqual(isHash160, false) }) }) }) @@ -465,7 +465,7 @@ describe('#address.js', () => { MAINNET_ADDRESSES.forEach(address => { it(`should detect ${address} is a mainnet address`, () => { const isMainnet = bchjs.Address.isMainnetAddress(address) - assert.equal(isMainnet, true) + assert.strictEqual(isMainnet, true) }) }) }) @@ -474,14 +474,14 @@ describe('#address.js', () => { TESTNET_ADDRESSES.forEach(address => { it(`should detect ${address} is not a mainnet address`, () => { const isMainnet = bchjs.Address.isMainnetAddress(address) - assert.equal(isMainnet, false) + assert.strictEqual(isMainnet, false) }) }) REGTEST_ADDRESSES.forEach(address => { it(`should detect ${address} is not a mainnet address`, () => { const isMainnet = bchjs.Address.isMainnetAddress(address) - assert.equal(isMainnet, false) + assert.strictEqual(isMainnet, false) }) }) }) @@ -503,7 +503,7 @@ describe('#address.js', () => { TESTNET_ADDRESSES.forEach(address => { it(`should detect ${address} is a testnet address`, () => { const isTestnet = bchjs.Address.isTestnetAddress(address) - assert.equal(isTestnet, true) + assert.strictEqual(isTestnet, true) }) }) }) @@ -512,14 +512,14 @@ describe('#address.js', () => { MAINNET_ADDRESSES.forEach(address => { it(`should detect ${address} is not a testnet address`, () => { const isTestnet = bchjs.Address.isTestnetAddress(address) - assert.equal(isTestnet, false) + assert.strictEqual(isTestnet, false) }) }) REGTEST_ADDRESSES.forEach(address => { it(`should detect ${address} is not a testnet address`, () => { const isTestnet = bchjs.Address.isTestnetAddress(address) - assert.equal(isTestnet, false) + assert.strictEqual(isTestnet, false) }) }) }) @@ -541,7 +541,7 @@ describe('#address.js', () => { REGTEST_ADDRESSES.forEach(address => { it(`should detect ${address} is a regtest address`, () => { const isRegTest = bchjs.Address.isRegTestAddress(address) - assert.equal(isRegTest, true) + assert.strictEqual(isRegTest, true) }) }) }) @@ -550,14 +550,14 @@ describe('#address.js', () => { MAINNET_ADDRESSES.forEach(address => { it(`should detect ${address} is not a regtest address`, () => { const isRegTest = bchjs.Address.isRegTestAddress(address) - assert.equal(isRegTest, false) + assert.strictEqual(isRegTest, false) }) }) TESTNET_ADDRESSES.forEach(address => { it(`should detect ${address} is not a regtest address`, () => { const isRegTest = bchjs.Address.isRegTestAddress(address) - assert.equal(isRegTest, false) + assert.strictEqual(isRegTest, false) }) }) }) @@ -581,7 +581,7 @@ describe('#address.js', () => { P2PKH_ADDRESSES.forEach(address => { it(`should detect ${address} is a P2PKH address`, () => { const isP2PKH = bchjs.Address.isP2PKHAddress(address) - assert.equal(isP2PKH, true) + assert.strictEqual(isP2PKH, true) }) }) }) @@ -590,7 +590,7 @@ describe('#address.js', () => { P2SH_ADDRESSES.forEach(address => { it(`should detect ${address} is not a P2PKH address`, () => { const isP2PKH = bchjs.Address.isP2PKHAddress(address) - assert.equal(isP2PKH, false) + assert.strictEqual(isP2PKH, false) }) }) }) @@ -612,7 +612,7 @@ describe('#address.js', () => { P2SH_ADDRESSES.forEach(address => { it(`should detect ${address} is a P2SH address`, () => { const isP2SH = bchjs.Address.isP2SHAddress(address) - assert.equal(isP2SH, true) + assert.strictEqual(isP2SH, true) }) }) }) @@ -621,7 +621,7 @@ describe('#address.js', () => { P2PKH_ADDRESSES.forEach(address => { it(`should detect ${address} is not a P2SH address`, () => { const isP2SH = bchjs.Address.isP2SHAddress(address) - assert.equal(isP2SH, false) + assert.strictEqual(isP2SH, false) }) }) }) @@ -641,7 +641,7 @@ describe('#address.js', () => { describe('cashaddr prefix detection', () => { it('should return the same result for detectAddressFormat', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.detectAddressFormat(address) ), @@ -649,7 +649,7 @@ describe('#address.js', () => { bchjs.Address.detectAddressFormat(address) ) ) - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.detectAddressFormat(address) ), @@ -659,7 +659,7 @@ describe('#address.js', () => { ) }) it('should return the same result for detectAddressNetwork', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.detectAddressNetwork(address) ), @@ -667,7 +667,7 @@ describe('#address.js', () => { bchjs.Address.detectAddressNetwork(address) ) ) - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.detectAddressNetwork(address) ), @@ -677,7 +677,7 @@ describe('#address.js', () => { ) }) it('should return the same result for detectAddressType', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.detectAddressType(address) ), @@ -685,7 +685,7 @@ describe('#address.js', () => { bchjs.Address.detectAddressType(address) ) ) - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.detectAddressType(address) ), @@ -695,7 +695,7 @@ describe('#address.js', () => { ) }) it('should return the same result for toLegacyAddress', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.toLegacyAddress(address) ), @@ -703,7 +703,7 @@ describe('#address.js', () => { bchjs.Address.toLegacyAddress(address) ) ) - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.toLegacyAddress(address) ), @@ -711,7 +711,7 @@ describe('#address.js', () => { ) }) it('should return the same result for isLegacyAddress', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isLegacyAddress(address) ), @@ -719,7 +719,7 @@ describe('#address.js', () => { bchjs.Address.isLegacyAddress(address) ) ) - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isLegacyAddress(address) ), @@ -727,13 +727,13 @@ describe('#address.js', () => { ) }) it('should return the same result for isCashAddress', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isCashAddress(address) ), CASHADDR_ADDRESSES.map(address => bchjs.Address.isCashAddress(address)) ) - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isCashAddress(address) ), @@ -741,7 +741,7 @@ describe('#address.js', () => { ) }) it('should return the same result for isMainnetAddress', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isMainnetAddress(address) ), @@ -749,7 +749,7 @@ describe('#address.js', () => { bchjs.Address.isMainnetAddress(address) ) ) - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isMainnetAddress(address) ), @@ -758,8 +758,9 @@ describe('#address.js', () => { ) ) }) + it('should return the same result for isTestnetAddress', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isTestnetAddress(address) ), @@ -767,7 +768,7 @@ describe('#address.js', () => { bchjs.Address.isTestnetAddress(address) ) ) - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isTestnetAddress(address) ), @@ -776,28 +777,30 @@ describe('#address.js', () => { ) ) }) + it('should return the same result for isP2PKHAddress', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isP2PKHAddress(address) ), CASHADDR_ADDRESSES.map(address => bchjs.Address.isP2PKHAddress(address)) ) - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isP2PKHAddress(address) ), REGTEST_ADDRESSES.map(address => bchjs.Address.isP2PKHAddress(address)) ) }) + it('should return the same result for isP2SHAddress', () => { - assert.deepEqual( + assert.deepStrictEqual( CASHADDR_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isP2SHAddress(address) ), CASHADDR_ADDRESSES.map(address => bchjs.Address.isP2SHAddress(address)) ) - assert.deepEqual( + assert.deepStrictEqual( REGTEST_ADDRESSES_NO_PREFIX.map(address => bchjs.Address.isP2SHAddress(address) ), @@ -810,21 +813,21 @@ describe('#address.js', () => { LEGACY_ADDRESSES.forEach(address => { it(`should detect ${address} is a legacy base58Check address`, () => { const isBase58Check = bchjs.Address.detectAddressFormat(address) - assert.equal(isBase58Check, 'legacy') + assert.strictEqual(isBase58Check, 'legacy') }) }) CASHADDR_ADDRESSES.forEach(address => { it(`should detect ${address} is a legacy cashaddr address`, () => { const isCashaddr = bchjs.Address.detectAddressFormat(address) - assert.equal(isCashaddr, 'cashaddr') + assert.strictEqual(isCashaddr, 'cashaddr') }) }) REGTEST_ADDRESSES.forEach(address => { it(`should detect ${address} is a legacy cashaddr address`, () => { const isCashaddr = bchjs.Address.detectAddressFormat(address) - assert.equal(isCashaddr, 'cashaddr') + assert.strictEqual(isCashaddr, 'cashaddr') }) }) @@ -844,21 +847,21 @@ describe('#address.js', () => { MAINNET_ADDRESSES.forEach(address => { it(`should detect ${address} is a mainnet address`, () => { const isMainnet = bchjs.Address.detectAddressNetwork(address) - assert.equal(isMainnet, 'mainnet') + assert.strictEqual(isMainnet, 'mainnet') }) }) TESTNET_ADDRESSES.forEach(address => { it(`should detect ${address} is a testnet address`, () => { const isTestnet = bchjs.Address.detectAddressNetwork(address) - assert.equal(isTestnet, 'testnet') + assert.strictEqual(isTestnet, 'testnet') }) }) REGTEST_ADDRESSES.forEach(address => { it(`should detect ${address} is a testnet address`, () => { const isTestnet = bchjs.Address.detectAddressNetwork(address) - assert.equal(isTestnet, 'regtest') + assert.strictEqual(isTestnet, 'regtest') }) }) @@ -878,14 +881,14 @@ describe('#address.js', () => { P2PKH_ADDRESSES.forEach(address => { it(`should detect ${address} is a P2PKH address`, () => { const isP2PKH = bchjs.Address.detectAddressType(address) - assert.equal(isP2PKH, 'p2pkh') + assert.strictEqual(isP2PKH, 'p2pkh') }) }) P2SH_ADDRESSES.forEach(address => { it(`should detect ${address} is a P2SH address`, () => { const isP2SH = bchjs.Address.detectAddressType(address) - assert.equal(isP2SH, 'p2sh') + assert.strictEqual(isP2SH, 'p2sh') }) }) @@ -905,7 +908,7 @@ describe('#address.js', () => { XPUBS.forEach((xpub, i) => { xpub.addresses.forEach((address, j) => { it(`generate public external change address ${j} for ${xpub.xpub}`, () => { - assert.equal(bchjs.Address.fromXPub(xpub.xpub, `0/${j}`), address) + assert.strictEqual(bchjs.Address.fromXPub(xpub.xpub, `0/${j}`), address) }) }) }) @@ -921,14 +924,14 @@ describe('#address.js', () => { ]) // hash160 script buffer - const p2sh_hash160 = bchjs.Crypto.hash160(script) + const p2shHash160 = bchjs.Crypto.hash160(script) // encode hash160 as P2SH output - const scriptPubKey = bchjs.Script.scriptHash.output.encode(p2sh_hash160) + const scriptPubKey = bchjs.Script.scriptHash.output.encode(p2shHash160) const p2shAddress = bchjs.Address.fromOutputScript(scriptPubKey) fixtures.p2shMainnet.forEach((address, i) => { - assert.equal(p2shAddress, address) + assert.strictEqual(p2shAddress, address) }) }) }) diff --git a/test/unit/blockchain.js b/test/unit/blockchain.js index de3dd73..f1415e3 100644 --- a/test/unit/blockchain.js +++ b/test/unit/blockchain.js @@ -60,14 +60,14 @@ describe('#Blockchain', () => { } it('should get block by hash', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getBlock( '00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09' ) .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -105,12 +105,12 @@ describe('#Blockchain', () => { } it('should get blockchain info', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getBlockchainInfo() .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -123,12 +123,12 @@ describe('#Blockchain', () => { const data = 527810 it('should get block count', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getBlockCount() .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -142,12 +142,12 @@ describe('#Blockchain', () => { '000000000000000001d127592d091d4c45062504663c9acab27a1b16c028e3c0' it('should get block hash by height', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getBlockHash(527810) .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -177,7 +177,7 @@ describe('#Blockchain', () => { } it('should get block header by hash', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getBlockHeader( @@ -185,7 +185,7 @@ describe('#Blockchain', () => { true ) .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -198,12 +198,12 @@ describe('#Blockchain', () => { const data = '577528469277.1339' it('should get difficulty', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getDifficulty() .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -216,7 +216,7 @@ describe('#Blockchain', () => { const data = 'Transaction not in mempool' it('should get mempool ancestors', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getMempoolAncestors( @@ -224,7 +224,7 @@ describe('#Blockchain', () => { true ) .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -239,7 +239,7 @@ describe('#Blockchain', () => { } it('should get mempool descendants', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getMempoolDescendants( @@ -247,7 +247,7 @@ describe('#Blockchain', () => { true ) .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -262,14 +262,14 @@ describe('#Blockchain', () => { } it('should get mempool entry', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getMempoolEntry( 'daf58932cb91619304dd4cbd03c7202e89ad7d6cbd6e2209e5f64ce3b6ed7c88' ) .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -290,12 +290,12 @@ describe('#Blockchain', () => { } it('should get mempool info', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getMempoolInfo() .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -331,12 +331,12 @@ describe('#Blockchain', () => { } it('should get mempool info', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.getRawMempool() .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -430,12 +430,12 @@ describe('#Blockchain', () => { } it('should get TODO', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.preciousBlock() .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -448,12 +448,12 @@ describe('#Blockchain', () => { const data = 'Cannot prune blocks because node is not in prune mode.' it('should prune blockchain', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'post').returns(resolved) bchjs.Blockchain.pruneBlockchain(507) .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -466,12 +466,12 @@ describe('#Blockchain', () => { const data = true it('should verify blockchain', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.verifyChain(3, 6) .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -484,12 +484,12 @@ describe('#Blockchain', () => { const data = "proof must be hexadecimal string (not '')" it('should verify utxo proof', done => { - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Blockchain.verifyTxOutProof('3') .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) diff --git a/test/unit/control.js b/test/unit/control.js index ba39935..2c8f866 100644 --- a/test/unit/control.js +++ b/test/unit/control.js @@ -24,12 +24,12 @@ describe('#Control', () => { relayfee: 0.00001, errors: '' } - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Control.getNetworkInfo() .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -51,12 +51,12 @@ describe('#Control', () => { chunks_free: 1 } } - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Control.getMemoryInfo() .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) diff --git a/test/unit/fixtures/ipfs-mock.js b/test/unit/fixtures/ipfs-mock.js index 4165319..fece65a 100644 --- a/test/unit/fixtures/ipfs-mock.js +++ b/test/unit/fixtures/ipfs-mock.js @@ -64,7 +64,7 @@ const paymentInfo = { } } -mockNewFileModel = { +const mockNewFileModel = { success: true, hostingCostBCH: 0.00004197, hostingCostUSD: 0.01, diff --git a/test/unit/fixtures/slp/mock-utils.js b/test/unit/fixtures/slp/mock-utils.js index 928e09a..a6245af 100644 --- a/test/unit/fixtures/slp/mock-utils.js +++ b/test/unit/fixtures/slp/mock-utils.js @@ -399,7 +399,7 @@ const nonSLPTxDetailsWithOpReturn = { blocktime: 1565380800 } -txDetailsSLPGenesis = { +const txDetailsSLPGenesis = { txid: 'bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90', hash: 'bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90', version: 2, @@ -1319,5 +1319,6 @@ module.exports = { mockValidateTxid3Valid, mockValidateTxid3Invalid, whitelist, - slpdbStatus + slpdbStatus, + mockValidateTxidArray } diff --git a/test/unit/generating.js b/test/unit/generating.js index 50e869b..27f8142 100644 --- a/test/unit/generating.js +++ b/test/unit/generating.js @@ -20,7 +20,7 @@ describe('#Generating', () => { it('should generate', done => { const data = [] - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'post').returns(resolved) bchjs.Generating.generateToAddress( @@ -28,7 +28,7 @@ describe('#Generating', () => { 'bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf' ) .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) diff --git a/test/unit/hdnode.js b/test/unit/hdnode.js index e24774d..0c14d02 100644 --- a/test/unit/hdnode.js +++ b/test/unit/hdnode.js @@ -4,7 +4,7 @@ const Buffer = require('safe-buffer').Buffer // Mocks const fixtures = require('./fixtures/hdnode.json') -const slpFixtures = require('./fixtures/slp/address.json') +// const slpFixtures = require('./fixtures/slp/address.json') // Unit under test (uut) const BCHJS = require('../../src/bch-js') @@ -20,7 +20,7 @@ describe('#HDNode', () => { it('should create an HDNode from root seed buffer', async () => { const rootSeedBuffer = await bchjs.Mnemonic.toSeed(mnemonic) const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) - assert.notEqual(hdNode, null) + assert.notStrictEqual(hdNode, null) }) }) }) @@ -31,8 +31,8 @@ describe('#HDNode', () => { const rootSeedBuffer = await bchjs.Mnemonic.toSeed(derive.mnemonic) const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const childHDNode = bchjs.HDNode.derive(hdNode, 0) - assert.equal(bchjs.HDNode.toXPub(childHDNode), derive.xpub) - assert.equal(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) + assert.strictEqual(bchjs.HDNode.toXPub(childHDNode), derive.xpub) + assert.strictEqual(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) }) }) }) @@ -43,8 +43,8 @@ describe('#HDNode', () => { const rootSeedBuffer = await bchjs.Mnemonic.toSeed(derive.mnemonic) const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const childHDNode = bchjs.HDNode.deriveHardened(hdNode, 0) - assert.equal(bchjs.HDNode.toXPub(childHDNode), derive.xpub) - assert.equal(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) + assert.strictEqual(bchjs.HDNode.toXPub(childHDNode), derive.xpub) + assert.strictEqual(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) }) }) @@ -56,8 +56,8 @@ describe('#HDNode', () => { const purpose = bchjs.HDNode.deriveHardened(hdNode, 44) const coin = bchjs.HDNode.deriveHardened(purpose, 145) const childHDNode = bchjs.HDNode.deriveHardened(coin, 0) - assert.equal(bchjs.HDNode.toXPub(childHDNode), derive.xpub) - assert.equal(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) + assert.strictEqual(bchjs.HDNode.toXPub(childHDNode), derive.xpub) + assert.strictEqual(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) }) }) }) @@ -70,8 +70,8 @@ describe('#HDNode', () => { const rootSeedBuffer = await bchjs.Mnemonic.toSeed(derive.mnemonic) const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const childHDNode = bchjs.HDNode.derivePath(hdNode, '0') - assert.equal(bchjs.HDNode.toXPub(childHDNode), derive.xpub) - assert.equal(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) + assert.strictEqual(bchjs.HDNode.toXPub(childHDNode), derive.xpub) + assert.strictEqual(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) }) }) }) @@ -82,8 +82,8 @@ describe('#HDNode', () => { const rootSeedBuffer = await bchjs.Mnemonic.toSeed(derive.mnemonic) const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const childHDNode = bchjs.HDNode.derivePath(hdNode, "0'") - assert.equal(bchjs.HDNode.toXPub(childHDNode), derive.xpub) - assert.equal(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) + assert.strictEqual(bchjs.HDNode.toXPub(childHDNode), derive.xpub) + assert.strictEqual(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) }) }) }) @@ -94,8 +94,8 @@ describe('#HDNode', () => { const rootSeedBuffer = await bchjs.Mnemonic.toSeed(derive.mnemonic) const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const childHDNode = bchjs.HDNode.derivePath(hdNode, "44'/145'/0'") - assert.equal(bchjs.HDNode.toXPub(childHDNode), derive.xpub) - assert.equal(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) + assert.strictEqual(bchjs.HDNode.toXPub(childHDNode), derive.xpub) + assert.strictEqual(bchjs.HDNode.toXPriv(childHDNode), derive.xpriv) }) }) }) @@ -108,7 +108,7 @@ describe('#HDNode', () => { const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const childHDNode = bchjs.HDNode.derivePath(hdNode, '0') const addy = bchjs.HDNode.toLegacyAddress(childHDNode) - assert.equal(addy, fixture.address) + assert.strictEqual(addy, fixture.address) }) }) }) @@ -120,7 +120,7 @@ describe('#HDNode', () => { const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const childHDNode = bchjs.HDNode.derivePath(hdNode, '0') const addy = bchjs.HDNode.toCashAddress(childHDNode) - assert.equal(addy, fixture.address) + assert.strictEqual(addy, fixture.address) }) it(`should get address ${fixture.regtestAddress} from HDNode`, async () => { @@ -128,7 +128,7 @@ describe('#HDNode', () => { const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const childHDNode = bchjs.HDNode.derivePath(hdNode, '0') const addr = bchjs.HDNode.toCashAddress(childHDNode, true) - assert.equal(addr, fixture.regtestAddress) + assert.strictEqual(addr, fixture.regtestAddress) }) }) }) @@ -137,7 +137,7 @@ describe('#HDNode', () => { fixtures.toWIF.forEach(fixture => { it(`should get privateKeyWIF ${fixture.privateKeyWIF} from HDNode`, () => { const hdNode = bchjs.HDNode.fromXPriv(fixture.xpriv) - assert.equal(bchjs.HDNode.toWIF(hdNode), fixture.privateKeyWIF) + assert.strictEqual(bchjs.HDNode.toWIF(hdNode), fixture.privateKeyWIF) }) }) }) @@ -148,7 +148,7 @@ describe('#HDNode', () => { const rootSeedBuffer = await bchjs.Mnemonic.toSeed(fixture.mnemonic) const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const xpub = bchjs.HDNode.toXPub(hdNode) - assert.equal(xpub, fixture.xpub) + assert.strictEqual(xpub, fixture.xpub) }) }) }) @@ -159,7 +159,7 @@ describe('#HDNode', () => { const rootSeedBuffer = await bchjs.Mnemonic.toSeed(fixture.mnemonic) const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const xpriv = bchjs.HDNode.toXPriv(hdNode) - assert.equal(xpriv, fixture.xpriv) + assert.strictEqual(xpriv, fixture.xpriv) }) }) }) @@ -170,7 +170,7 @@ describe('#HDNode', () => { const rootSeedBuffer = await bchjs.Mnemonic.toSeed(fixture.mnemonic) const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const keyPair = bchjs.HDNode.toKeyPair(hdNode) - assert.equal(typeof keyPair, 'object') + assert.strictEqual(typeof keyPair, 'object') }) }) }) @@ -181,7 +181,7 @@ describe('#HDNode', () => { const rootSeedBuffer = await bchjs.Mnemonic.toSeed(fixture.mnemonic) const hdNode = bchjs.HDNode.fromSeed(rootSeedBuffer) const publicKeyBuffer = bchjs.HDNode.toPublicKey(hdNode) - assert.equal(typeof publicKeyBuffer, 'object') + assert.strictEqual(typeof publicKeyBuffer, 'object') }) }) }) @@ -195,30 +195,30 @@ describe('#HDNode', () => { }) it(`should export xpriv ${fixture.xpriv}`, () => { - assert.equal(bchjs.HDNode.toXPriv(hdNode), fixture.xpriv) + assert.strictEqual(bchjs.HDNode.toXPriv(hdNode), fixture.xpriv) }) it(`should export xpub ${fixture.xpub}`, () => { - assert.equal(bchjs.HDNode.toXPub(hdNode), fixture.xpub) + assert.strictEqual(bchjs.HDNode.toXPub(hdNode), fixture.xpub) }) it(`should export legacy address ${fixture.legacy}`, () => { - assert.equal(bchjs.HDNode.toLegacyAddress(hdNode), fixture.legacy) + assert.strictEqual(bchjs.HDNode.toLegacyAddress(hdNode), fixture.legacy) }) it(`should export cashaddress ${fixture.cashaddress}`, () => { - assert.equal(bchjs.HDNode.toCashAddress(hdNode), fixture.cashaddress) + assert.strictEqual(bchjs.HDNode.toCashAddress(hdNode), fixture.cashaddress) }) it(`should export regtest cashaddress ${fixture.regtestaddress}`, () => { - assert.equal( + assert.strictEqual( bchjs.HDNode.toCashAddress(hdNode, true), fixture.regtestaddress ) }) it(`should export privateKeyWIF ${fixture.privateKeyWIF}`, () => { - assert.equal(bchjs.HDNode.toWIF(hdNode), fixture.privateKeyWIF) + assert.strictEqual(bchjs.HDNode.toWIF(hdNode), fixture.privateKeyWIF) }) }) }) @@ -233,19 +233,19 @@ describe('#HDNode', () => { }) it(`should export xpub ${fixture.xpub}`, () => { - assert.equal(bchjs.HDNode.toXPub(hdNode), fixture.xpub) + assert.strictEqual(bchjs.HDNode.toXPub(hdNode), fixture.xpub) }) it(`should export legacy address ${fixture.legacy}`, () => { - assert.equal(bchjs.HDNode.toLegacyAddress(hdNode), fixture.legacy) + assert.strictEqual(bchjs.HDNode.toLegacyAddress(hdNode), fixture.legacy) }) it(`should export cashaddress ${fixture.cashaddress}`, () => { - assert.equal(bchjs.HDNode.toCashAddress(hdNode), fixture.cashaddress) + assert.strictEqual(bchjs.HDNode.toCashAddress(hdNode), fixture.cashaddress) }) it(`should export regtest cashaddress ${fixture.regtestaddress}`, () => { - assert.equal( + assert.strictEqual( bchjs.HDNode.toCashAddress(hdNode, true), fixture.regtestaddress ) @@ -273,7 +273,7 @@ describe('#HDNode', () => { account.getChainAddress(0) ) it(`should create external change address ${external1}`, () => { - assert.equal(external1, fixture.externals[0]) + assert.strictEqual(external1, fixture.externals[0]) }) }) @@ -281,7 +281,7 @@ describe('#HDNode', () => { for (let i = 0; i < 4; i++) { const ex = bchjs.Address.toCashAddress(account.nextChainAddress(0)) it(`should create external change address ${ex}`, () => { - assert.equal(ex, fixture.externals[i + 1]) + assert.strictEqual(ex, fixture.externals[i + 1]) }) } }) @@ -295,7 +295,7 @@ describe('#HDNode', () => { const hdnode = bchjs.HDNode.fromXPriv(fixture.privateKeyWIF) const buf = Buffer.from(bchjs.Crypto.sha256(fixture.data), 'hex') const signatureBuf = bchjs.HDNode.sign(hdnode, buf) - assert.equal(typeof signatureBuf, 'object') + assert.strictEqual(typeof signatureBuf, 'object') }) }) }) @@ -307,7 +307,7 @@ describe('#HDNode', () => { const buf = Buffer.from(bchjs.Crypto.sha256(fixture.data), 'hex') const signature = bchjs.HDNode.sign(hdnode1, buf) const verify = bchjs.HDNode.verify(hdnode1, buf, signature) - assert.equal(verify, true) + assert.strictEqual(verify, true) }) }) }) @@ -316,14 +316,14 @@ describe('#HDNode', () => { fixtures.isPublic.forEach(fixture => { it('should verify hdnode is public', () => { const node = bchjs.HDNode.fromXPub(fixture.xpub) - assert.equal(bchjs.HDNode.isPublic(node), true) + assert.strictEqual(bchjs.HDNode.isPublic(node), true) }) }) fixtures.isPublic.forEach(fixture => { it('should verify hdnode is not public', () => { const node = bchjs.HDNode.fromXPriv(fixture.xpriv) - assert.equal(bchjs.HDNode.isPublic(node), false) + assert.strictEqual(bchjs.HDNode.isPublic(node), false) }) }) }) @@ -332,14 +332,14 @@ describe('#HDNode', () => { fixtures.isPrivate.forEach(fixture => { it('should verify hdnode is not private', () => { const node = bchjs.HDNode.fromXPub(fixture.xpub) - assert.equal(bchjs.HDNode.isPrivate(node), false) + assert.strictEqual(bchjs.HDNode.isPrivate(node), false) }) }) fixtures.isPrivate.forEach(fixture => { it('should verify hdnode is private', () => { const node = bchjs.HDNode.fromXPriv(fixture.xpriv) - assert.equal(bchjs.HDNode.isPrivate(node), true) + assert.strictEqual(bchjs.HDNode.isPrivate(node), true) }) }) }) @@ -351,7 +351,7 @@ describe('#HDNode', () => { const publicKeyBuffer = bchjs.HDNode.toPublicKey(node) const hash160 = bchjs.Crypto.hash160(publicKeyBuffer) const identifier = bchjs.HDNode.toIdentifier(node) - assert.equal(identifier.toString('hex'), hash160.toString('hex')) + assert.strictEqual(identifier.toString('hex'), hash160.toString('hex')) }) }) }) diff --git a/test/unit/ipfs.js b/test/unit/ipfs.js index 1207824..85f6b30 100644 --- a/test/unit/ipfs.js +++ b/test/unit/ipfs.js @@ -41,7 +41,7 @@ describe('#IPFS', () => { }) it('should create a new file model', async () => { - const path = `${__dirname}/ipfs.js` + const path = `${__dirname.toString()}/ipfs.js` sandbox .stub(bchjs.IPFS.axios, 'post') @@ -87,7 +87,7 @@ describe('#IPFS', () => { it('should throw an error if modelId is not included', async () => { try { - const path = `${__dirname}/ipfs.js` + const path = `${__dirname.toString()}/ipfs.js` await bchjs.IPFS.uploadFileServer(path) @@ -110,7 +110,7 @@ describe('#IPFS', () => { } sandbox.stub(bchjs.IPFS.uppy, 'upload').resolves(mock) - const path = `${__dirname}/ipfs.js` + const path = `${__dirname.toString()}/ipfs.js` await bchjs.IPFS.uploadFileServer(path, '5ec562319bfacc745e8d8a52') assert.equal(true, false, 'Unexpected result') @@ -124,7 +124,7 @@ describe('#IPFS', () => { try { sandbox.stub(bchjs.IPFS.uppy, 'upload').resolves(mockData.uploadData) - const path = `${__dirname}/ipfs.js` + const path = `${__dirname.toString()}/ipfs.js` const result = await bchjs.IPFS.uploadFileServer( path, '5ec562319bfacc745e8d8a52' diff --git a/test/unit/mining.js b/test/unit/mining.js index 9397f5a..d75a785 100644 --- a/test/unit/mining.js +++ b/test/unit/mining.js @@ -30,12 +30,12 @@ describe('#Mining', () => { sigops: 2 } - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Mining.getBlockTemplate('') .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -59,12 +59,12 @@ describe('#Mining', () => { chain: 'main' } - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Mining.getMiningInfo() .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) @@ -78,12 +78,12 @@ describe('#Mining', () => { it('should get network hashps', done => { const data = 3586365937646890000 - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Mining.getNetworkHashps() .then(result => { - assert.equal(data, result) + assert.strictEqual(data, result) }) .then(done, done) }) @@ -98,12 +98,12 @@ describe('#Mining', () => { it('should TODO', done => { const data = {} - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'post').returns(resolved) bchjs.Mining.submitBlock() .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) }) diff --git a/test/unit/raw-tranactions.js b/test/unit/raw-tranactions.js index 2b31c9a..eaf682a 100644 --- a/test/unit/raw-tranactions.js +++ b/test/unit/raw-tranactions.js @@ -41,12 +41,12 @@ describe('#RawTransactions', () => { vout: [] } - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.RawTransactions.decodeRawTransaction('02000000000000000000') .then(result => { - assert.equal(data, result) + assert.strictEqual(data, result) }) .then(done, done) }) @@ -64,7 +64,7 @@ describe('#RawTransactions', () => { p2sh: 'bitcoincash:prswx5965nfumux9qng5kj8hw603vcne7q08t8c6jp' } - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) const result = await bchjs.RawTransactions.decodeScript( @@ -72,7 +72,7 @@ describe('#RawTransactions', () => { ) // console.log(`result: ${util.inspect(result)}`) - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) }) @@ -85,14 +85,14 @@ describe('#RawTransactions', () => { const data = '020000000160d663961c63c7f0a07f22ec07b8f55b3935bfdbed8b1d8454916e8932fbf109010000006b4830450221008479fab4cfdcb111833d250a43f98ac26d43272b7a29cb1b9a0491eae5c44b3502203448b17253632395c29a7d62058bbfe93efb20fc8636ba6837002d464195aec04121029123258f7cdcd45b864066bcaa9b71f24d5ed1fa1dd36eaf107d8432b5014658ffffffff016d180000000000001976a91479d3297d1823149f4ec61df31d19f2fad5390c0288ac00000000' - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.RawTransactions.getRawTransaction( '808d617eccaad4f1397fe07a06ec5ed15a0821cf22a3e0931c0c92aef9e572b6' ) .then(result => { - assert.equal(data, result) + assert.strictEqual(data, result) }) .then(done, done) }) @@ -106,14 +106,14 @@ describe('#RawTransactions', () => { it('should send single raw transaction', async () => { const data = 'Error: transaction already in block chain' - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) const result = await bchjs.RawTransactions.sendRawTransaction( '020000000160d663961c63c7f0a07f22ec07b8f55b3935bfdbed8b1d8454916e8932fbf109010000006b4830450221008479fab4cfdcb111833d250a43f98ac26d43272b7a29cb1b9a0491eae5c44b3502203448b17253632395c29a7d62058bbfe93efb20fc8636ba6837002d464195aec04121029123258f7cdcd45b864066bcaa9b71f24d5ed1fa1dd36eaf107d8432b5014658ffffffff016d180000000000001976a91479d3297d1823149f4ec61df31d19f2fad5390c0288ac00000000' ) - assert.equal(data, result) + assert.strictEqual(data, result) }) // it("should send an array of raw transactions", async () => { @@ -129,7 +129,7 @@ describe('#RawTransactions', () => { // "020000000160d663961c63c7f0a07f22ec07b8f55b3935bfdbed8b1d8454916e8932fbf109010000006b4830450221008479fab4cfdcb111833d250a43f98ac26d43272b7a29cb1b9a0491eae5c44b3502203448b17253632395c29a7d62058bbfe93efb20fc8636ba6837002d464195aec04121029123258f7cdcd45b864066bcaa9b71f24d5ed1fa1dd36eaf107d8432b5014658ffffffff016d180000000000001976a91479d3297d1823149f4ec61df31d19f2fad5390c0288ac00000000" // ]) // - // assert.equal(data, result.data) + // assert.strictEqual(data, result.data) // }) }) }) diff --git a/test/unit/slp-tokentype1.js b/test/unit/slp-tokentype1.js index 920dd75..1ae90f4 100644 --- a/test/unit/slp-tokentype1.js +++ b/test/unit/slp-tokentype1.js @@ -193,279 +193,279 @@ describe('#SLP TokenType1', () => { }) }) - describe('#generateSendOpReturn04', () => { - it('should generate send OP_RETURN code', () => { - // Mock UTXO. - const tokenUtxos = [ - { - address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', - decimals: 9, - height: 660974, - isValid: true, - satoshis: 546, - tokenDocumentHash: '', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - tokenName: 'Cash Tab Points', - tokenQty: 1000000000, - tokenTicker: 'CTP', - tokenType: 1, - transactionType: 'send', - tx_hash: - '2922728e4febc21523369902615165bc15753f79f7488d3f1a260808ff0e116d', - tx_pos: 1, - txid: - '2922728e4febc21523369902615165bc15753f79f7488d3f1a260808ff0e116d', - utxoType: 'token', - value: 546, - vout: 1 - }, - { - address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', - decimals: 9, - height: 0, - isValid: true, - satoshis: 546, - tokenDocumentHash: '', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - tokenName: 'Cash Tab Points', - tokenQty: 1.000000001, - tokenTicker: 'CTP', - tokenType: 1, - transactionType: 'send', - tx_hash: - '2ae85b47d9dc61bd90909048d057234efe9508bcc6a599708d029122ed113515', - tx_pos: 1, - txid: - '2ae85b47d9dc61bd90909048d057234efe9508bcc6a599708d029122ed113515', - utxoType: 'token', - value: 546, - vout: 1 - }, - { - address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', - decimals: 9, - height: 0, - isValid: true, - satoshis: 546, - tokenDocumentHash: '', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - tokenName: 'Cash Tab Points', - tokenQty: 1, - tokenTicker: 'CTP', - tokenType: 1, - transactionType: 'send', - tx_hash: - '4ebd5acb0f3c4edefb9d15295cc2e14f4dada90a3ff0ee17cf77efc57e2940a1', - tx_pos: 1, - txid: - '4ebd5acb0f3c4edefb9d15295cc2e14f4dada90a3ff0ee17cf77efc57e2940a1', - utxoType: 'token', - value: 546, - vout: 1 - }, - { - address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', - decimals: 9, - height: 0, - isValid: true, - satoshis: 546, - tokenDocumentHash: '', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - tokenName: 'Cash Tab Points', - tokenQty: 1, - tokenTicker: 'CTP', - tokenType: 1, - transactionType: 'send', - tx_hash: - '5ed96f59ae4fec31ee8fc96304bd610c3658f9df2fde35119aad6f44547420f9', - tx_pos: 1, - txid: - '5ed96f59ae4fec31ee8fc96304bd610c3658f9df2fde35119aad6f44547420f9', - utxoType: 'token', - value: 546, - vout: 1 - }, - { - address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', - decimals: 9, - height: 0, - isValid: true, - satoshis: 546, - tokenDocumentHash: '', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - tokenName: 'Cash Tab Points', - tokenQty: 1, - tokenTicker: 'CTP', - tokenType: 1, - transactionType: 'send', - tx_hash: - '648465087cc8ba218ccf6b7261256924ef2dc1d20e5c10117a6d555065c01600', - tx_pos: 1, - txid: - '648465087cc8ba218ccf6b7261256924ef2dc1d20e5c10117a6d555065c01600', - utxoType: 'token', - value: 546, - vout: 1 - } - ] + // describe('#generateSendOpReturn04', () => { + // it('should generate send OP_RETURN code', () => { + // // Mock UTXO. + // const tokenUtxos = [ + // { + // address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', + // decimals: 9, + // height: 660974, + // isValid: true, + // satoshis: 546, + // tokenDocumentHash: '', + // tokenDocumentUrl: 'https://cashtabapp.com/', + // tokenId: + // 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + // tokenName: 'Cash Tab Points', + // tokenQty: 1000000000, + // tokenTicker: 'CTP', + // tokenType: 1, + // transactionType: 'send', + // tx_hash: + // '2922728e4febc21523369902615165bc15753f79f7488d3f1a260808ff0e116d', + // tx_pos: 1, + // txid: + // '2922728e4febc21523369902615165bc15753f79f7488d3f1a260808ff0e116d', + // utxoType: 'token', + // value: 546, + // vout: 1 + // }, + // { + // address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', + // decimals: 9, + // height: 0, + // isValid: true, + // satoshis: 546, + // tokenDocumentHash: '', + // tokenDocumentUrl: 'https://cashtabapp.com/', + // tokenId: + // 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + // tokenName: 'Cash Tab Points', + // tokenQty: 1.000000001, + // tokenTicker: 'CTP', + // tokenType: 1, + // transactionType: 'send', + // tx_hash: + // '2ae85b47d9dc61bd90909048d057234efe9508bcc6a599708d029122ed113515', + // tx_pos: 1, + // txid: + // '2ae85b47d9dc61bd90909048d057234efe9508bcc6a599708d029122ed113515', + // utxoType: 'token', + // value: 546, + // vout: 1 + // }, + // { + // address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', + // decimals: 9, + // height: 0, + // isValid: true, + // satoshis: 546, + // tokenDocumentHash: '', + // tokenDocumentUrl: 'https://cashtabapp.com/', + // tokenId: + // 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + // tokenName: 'Cash Tab Points', + // tokenQty: 1, + // tokenTicker: 'CTP', + // tokenType: 1, + // transactionType: 'send', + // tx_hash: + // '4ebd5acb0f3c4edefb9d15295cc2e14f4dada90a3ff0ee17cf77efc57e2940a1', + // tx_pos: 1, + // txid: + // '4ebd5acb0f3c4edefb9d15295cc2e14f4dada90a3ff0ee17cf77efc57e2940a1', + // utxoType: 'token', + // value: 546, + // vout: 1 + // }, + // { + // address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', + // decimals: 9, + // height: 0, + // isValid: true, + // satoshis: 546, + // tokenDocumentHash: '', + // tokenDocumentUrl: 'https://cashtabapp.com/', + // tokenId: + // 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + // tokenName: 'Cash Tab Points', + // tokenQty: 1, + // tokenTicker: 'CTP', + // tokenType: 1, + // transactionType: 'send', + // tx_hash: + // '5ed96f59ae4fec31ee8fc96304bd610c3658f9df2fde35119aad6f44547420f9', + // tx_pos: 1, + // txid: + // '5ed96f59ae4fec31ee8fc96304bd610c3658f9df2fde35119aad6f44547420f9', + // utxoType: 'token', + // value: 546, + // vout: 1 + // }, + // { + // address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', + // decimals: 9, + // height: 0, + // isValid: true, + // satoshis: 546, + // tokenDocumentHash: '', + // tokenDocumentUrl: 'https://cashtabapp.com/', + // tokenId: + // 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + // tokenName: 'Cash Tab Points', + // tokenQty: 1, + // tokenTicker: 'CTP', + // tokenType: 1, + // transactionType: 'send', + // tx_hash: + // '648465087cc8ba218ccf6b7261256924ef2dc1d20e5c10117a6d555065c01600', + // tx_pos: 1, + // txid: + // '648465087cc8ba218ccf6b7261256924ef2dc1d20e5c10117a6d555065c01600', + // utxoType: 'token', + // value: 546, + // vout: 1 + // } + // ] + // + // const result = bchjs.SLP.TokenType1.generateSendOpReturn( + // tokenUtxos, + // 1000000004.000000001 + // ) + // // console.log(`result: ${JSON.stringify(result, null, 2)}`) + // + // assert.hasAllKeys(result, ['script', 'outputs']) + // assert.isNumber(result.outputs) + // }) + // }) - const result = bchjs.SLP.TokenType1.generateSendOpReturn( - tokenUtxos, - 1000000004.000000001 - ) - // console.log(`result: ${JSON.stringify(result, null, 2)}`) - - assert.hasAllKeys(result, ['script', 'outputs']) - assert.isNumber(result.outputs) - }) - }) - - describe('#generateSendOpReturn05', () => { - it('should generate send OP_RETURN code', () => { - // Mock UTXO. - const tokenUtxos = [ - { - address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', - decimals: 9, - height: 660974, - isValid: true, - satoshis: 546, - tokenDocumentHash: '', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - tokenName: 'Cash Tab Points', - tokenQty: 1000000000, - tokenTicker: 'CTP', - tokenType: 1, - transactionType: 'send', - tx_hash: - '2922728e4febc21523369902615165bc15753f79f7488d3f1a260808ff0e116d', - tx_pos: 1, - txid: - '2922728e4febc21523369902615165bc15753f79f7488d3f1a260808ff0e116d', - utxoType: 'token', - value: 546, - vout: 1 - }, - { - address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', - decimals: 9, - height: 0, - isValid: true, - satoshis: 546, - tokenDocumentHash: '', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - tokenName: 'Cash Tab Points', - tokenQty: 1.000000001, - tokenTicker: 'CTP', - tokenType: 1, - transactionType: 'send', - tx_hash: - '2ae85b47d9dc61bd90909048d057234efe9508bcc6a599708d029122ed113515', - tx_pos: 1, - txid: - '2ae85b47d9dc61bd90909048d057234efe9508bcc6a599708d029122ed113515', - utxoType: 'token', - value: 546, - vout: 1 - }, - { - address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', - decimals: 9, - height: 0, - isValid: true, - satoshis: 546, - tokenDocumentHash: '', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - tokenName: 'Cash Tab Points', - tokenQty: 1, - tokenTicker: 'CTP', - tokenType: 1, - transactionType: 'send', - tx_hash: - '4ebd5acb0f3c4edefb9d15295cc2e14f4dada90a3ff0ee17cf77efc57e2940a1', - tx_pos: 1, - txid: - '4ebd5acb0f3c4edefb9d15295cc2e14f4dada90a3ff0ee17cf77efc57e2940a1', - utxoType: 'token', - value: 546, - vout: 1 - }, - { - address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', - decimals: 9, - height: 0, - isValid: true, - satoshis: 546, - tokenDocumentHash: '', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - tokenName: 'Cash Tab Points', - tokenQty: 1, - tokenTicker: 'CTP', - tokenType: 1, - transactionType: 'send', - tx_hash: - '5ed96f59ae4fec31ee8fc96304bd610c3658f9df2fde35119aad6f44547420f9', - tx_pos: 1, - txid: - '5ed96f59ae4fec31ee8fc96304bd610c3658f9df2fde35119aad6f44547420f9', - utxoType: 'token', - value: 546, - vout: 1 - }, - { - address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', - decimals: 9, - height: 0, - isValid: true, - satoshis: 546, - tokenDocumentHash: '', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - tokenName: 'Cash Tab Points', - tokenQty: 1, - tokenTicker: 'CTP', - tokenType: 1, - transactionType: 'send', - tx_hash: - '648465087cc8ba218ccf6b7261256924ef2dc1d20e5c10117a6d555065c01600', - tx_pos: 1, - txid: - '648465087cc8ba218ccf6b7261256924ef2dc1d20e5c10117a6d555065c01600', - utxoType: 'token', - value: 546, - vout: 1 - } - ] - - const result = bchjs.SLP.TokenType1.generateSendOpReturn( - tokenUtxos, - 1000000003.500000001 - ) - // console.log(`result: ${JSON.stringify(result, null, 2)}`) - - assert.hasAllKeys(result, ['script', 'outputs']) - assert.isNumber(result.outputs) - }) - }) + // describe('#generateSendOpReturn05', () => { + // it('should generate send OP_RETURN code', () => { + // // Mock UTXO. + // const tokenUtxos = [ + // { + // address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', + // decimals: 9, + // height: 660974, + // isValid: true, + // satoshis: 546, + // tokenDocumentHash: '', + // tokenDocumentUrl: 'https://cashtabapp.com/', + // tokenId: + // 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + // tokenName: 'Cash Tab Points', + // tokenQty: 1000000000, + // tokenTicker: 'CTP', + // tokenType: 1, + // transactionType: 'send', + // tx_hash: + // '2922728e4febc21523369902615165bc15753f79f7488d3f1a260808ff0e116d', + // tx_pos: 1, + // txid: + // '2922728e4febc21523369902615165bc15753f79f7488d3f1a260808ff0e116d', + // utxoType: 'token', + // value: 546, + // vout: 1 + // }, + // { + // address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', + // decimals: 9, + // height: 0, + // isValid: true, + // satoshis: 546, + // tokenDocumentHash: '', + // tokenDocumentUrl: 'https://cashtabapp.com/', + // tokenId: + // 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + // tokenName: 'Cash Tab Points', + // tokenQty: 1.000000001, + // tokenTicker: 'CTP', + // tokenType: 1, + // transactionType: 'send', + // tx_hash: + // '2ae85b47d9dc61bd90909048d057234efe9508bcc6a599708d029122ed113515', + // tx_pos: 1, + // txid: + // '2ae85b47d9dc61bd90909048d057234efe9508bcc6a599708d029122ed113515', + // utxoType: 'token', + // value: 546, + // vout: 1 + // }, + // { + // address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', + // decimals: 9, + // height: 0, + // isValid: true, + // satoshis: 546, + // tokenDocumentHash: '', + // tokenDocumentUrl: 'https://cashtabapp.com/', + // tokenId: + // 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + // tokenName: 'Cash Tab Points', + // tokenQty: 1, + // tokenTicker: 'CTP', + // tokenType: 1, + // transactionType: 'send', + // tx_hash: + // '4ebd5acb0f3c4edefb9d15295cc2e14f4dada90a3ff0ee17cf77efc57e2940a1', + // tx_pos: 1, + // txid: + // '4ebd5acb0f3c4edefb9d15295cc2e14f4dada90a3ff0ee17cf77efc57e2940a1', + // utxoType: 'token', + // value: 546, + // vout: 1 + // }, + // { + // address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', + // decimals: 9, + // height: 0, + // isValid: true, + // satoshis: 546, + // tokenDocumentHash: '', + // tokenDocumentUrl: 'https://cashtabapp.com/', + // tokenId: + // 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + // tokenName: 'Cash Tab Points', + // tokenQty: 1, + // tokenTicker: 'CTP', + // tokenType: 1, + // transactionType: 'send', + // tx_hash: + // '5ed96f59ae4fec31ee8fc96304bd610c3658f9df2fde35119aad6f44547420f9', + // tx_pos: 1, + // txid: + // '5ed96f59ae4fec31ee8fc96304bd610c3658f9df2fde35119aad6f44547420f9', + // utxoType: 'token', + // value: 546, + // vout: 1 + // }, + // { + // address: 'bitcoincash:qpv9fx6mjdpgltygudnpw3tvmxdyzx7savhphtzswu', + // decimals: 9, + // height: 0, + // isValid: true, + // satoshis: 546, + // tokenDocumentHash: '', + // tokenDocumentUrl: 'https://cashtabapp.com/', + // tokenId: + // 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + // tokenName: 'Cash Tab Points', + // tokenQty: 1, + // tokenTicker: 'CTP', + // tokenType: 1, + // transactionType: 'send', + // tx_hash: + // '648465087cc8ba218ccf6b7261256924ef2dc1d20e5c10117a6d555065c01600', + // tx_pos: 1, + // txid: + // '648465087cc8ba218ccf6b7261256924ef2dc1d20e5c10117a6d555065c01600', + // utxoType: 'token', + // value: 546, + // vout: 1 + // } + // ] + // + // const result = bchjs.SLP.TokenType1.generateSendOpReturn( + // tokenUtxos, + // 1000000003.500000001 + // ) + // // console.log(`result: ${JSON.stringify(result, null, 2)}`) + // + // assert.hasAllKeys(result, ['script', 'outputs']) + // assert.isNumber(result.outputs) + // }) + // }) describe('#generateSendOpReturn06', () => { it('should generate send OP_RETURN code', () => { @@ -1370,7 +1370,7 @@ describe('#SLP TokenType1', () => { }) it('should generate genesis OP_RETURN code', () => { - tokenUtxo = [ + const tokenUtxo = [ { txid: '9d35c1803ed3ab8bd23c198b027f7b3b530586494dc265de6391b74a6b090136', diff --git a/test/unit/slp-utils.js b/test/unit/slp-utils.js index 180d600..9196db2 100644 --- a/test/unit/slp-utils.js +++ b/test/unit/slp-utils.js @@ -6,7 +6,7 @@ const cloneDeep = require('lodash.clonedeep') // Unit under test const SLP = require('../../src/slp/slp') let uut -let SERVER +// let SERVER const REST_URL = process.env.RESTURL ? process.env.RESTURL @@ -34,7 +34,7 @@ describe('#SLP Utils', () => { restURL: REST_URL, apiToken: process.env.BCHJSTOKEN }) - SERVER = uut.restURL + // SERVER = uut.restURL }) afterEach(() => { diff --git a/test/unit/transaction-builder.js b/test/unit/transaction-builder.js index 9b1899c..74b970b 100644 --- a/test/unit/transaction-builder.js +++ b/test/unit/transaction-builder.js @@ -1,5 +1,6 @@ const fixtures = require('./fixtures/transaction-builder.json') const assert = require('assert') +const assert2 = require('chai').assert const BCHJS = require('../../src/bch-js') const bchjs = new BCHJS() const Buffer = require('safe-buffer').Buffer @@ -9,7 +10,7 @@ describe('#TransactionBuilder', () => { const transactionBuilder = new bchjs.TransactionBuilder('mainnet') fixtures.hashTypes.forEach(fixture => { it('should match hash type', () => { - assert.equal( + assert2.equal( fixture[Object.keys(fixture)[0]], transactionBuilder.hashTypes[Object.keys(fixture)[0]] ) @@ -51,7 +52,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -88,7 +89,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -134,7 +135,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -178,7 +179,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -241,7 +242,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -302,7 +303,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -361,7 +362,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -418,7 +419,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -459,7 +460,7 @@ describe('#TransactionBuilder', () => { const tx = transactionBuilder.build() // output rawhex const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -496,7 +497,7 @@ describe('#TransactionBuilder', () => { const tx = transactionBuilder.build() // output rawhex const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -533,7 +534,7 @@ describe('#TransactionBuilder', () => { const tx = transactionBuilder.build() // output rawhex const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -579,7 +580,7 @@ describe('#TransactionBuilder', () => { const tx = transactionBuilder.build() // output rawhex const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -623,7 +624,7 @@ describe('#TransactionBuilder', () => { const tx = transactionBuilder.build() // output rawhex const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -667,7 +668,7 @@ describe('#TransactionBuilder', () => { const tx = transactionBuilder.build() // output rawhex const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) */ @@ -716,7 +717,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -763,7 +764,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -810,7 +811,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -853,7 +854,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -893,7 +894,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -933,7 +934,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -972,7 +973,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1007,7 +1008,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1042,7 +1043,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1096,7 +1097,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1124,7 +1125,7 @@ describe('#TransactionBuilder', () => { // let tx = transactionBuilder.build(); // // output rawhex // let hex = tx.toHex(); - // assert.equal(hex, fixture.hex); + // assert.strictEqual(hex, fixture.hex); // }); // }); // }); @@ -1185,7 +1186,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1214,7 +1215,7 @@ describe('#TransactionBuilder', () => { // let tx = transactionBuilder.build(); // // output rawhex // let hex = tx.toHex(); - // assert.equal(hex, fixture.hex); + // assert.strictEqual(hex, fixture.hex); // }); // }); // }); @@ -1297,7 +1298,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1323,7 +1324,7 @@ describe('#TransactionBuilder', () => { // transactionBuilder.sign(1, keyPair2, redeemScript, transactionBuilder.hashTypes.SIGHASH_ALL, fixture.amounts[1]); // let tx = transactionBuilder.build(); // let hex = tx.toHex(); - // assert.equal(hex, fixture.hex); + // assert.strictEqual(hex, fixture.hex); // }); // }); // }); @@ -1397,7 +1398,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1422,7 +1423,7 @@ describe('#TransactionBuilder', () => { // transactionBuilder.sign(1, keyPair2, redeemScript, transactionBuilder.hashTypes.SIGHASH_ALL, fixture.amounts[1]); // let tx = transactionBuilder.build(); // let hex = tx.toHex(); - // assert.equal(hex, fixture.hex); + // assert.strictEqual(hex, fixture.hex); // }); // }); // }); @@ -1482,7 +1483,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1510,7 +1511,7 @@ describe('#TransactionBuilder', () => { // let tx = transactionBuilder.build(); // // output rawhex // let hex = tx.toHex(); - // assert.equal(hex, fixture.hex); + // assert.strictEqual(hex, fixture.hex); // }); // }); // }); @@ -1579,7 +1580,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1608,7 +1609,7 @@ describe('#TransactionBuilder', () => { // let tx = transactionBuilder.build(); // // output rawhex // let hex = tx.toHex(); - // assert.equal(hex, fixture.hex); + // assert.strictEqual(hex, fixture.hex); // }); // }); // }); @@ -1702,7 +1703,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1728,7 +1729,7 @@ describe('#TransactionBuilder', () => { // transactionBuilder.sign(1, keyPair2, redeemScript, transactionBuilder.hashTypes.SIGHASH_ALL, fixture.amounts[1]); // let tx = transactionBuilder.build(); // let hex = tx.toHex(); - // assert.equal(hex, fixture.hex); + // assert.strictEqual(hex, fixture.hex); // }); // }); // }); @@ -1810,7 +1811,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1835,7 +1836,7 @@ describe('#TransactionBuilder', () => { // transactionBuilder.sign(1, keyPair2, redeemScript, transactionBuilder.hashTypes.SIGHASH_ALL, fixture.amounts[1]); // let tx = transactionBuilder.build(); // let hex = tx.toHex(); - // assert.equal(hex, fixture.hex); + // assert.strictEqual(hex, fixture.hex); // }); // }); // }); @@ -1873,7 +1874,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1908,7 +1909,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1943,7 +1944,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) @@ -1957,7 +1958,7 @@ describe('#TransactionBuilder', () => { const r = Buffer.from(fixture.r, 'hex') const s = Buffer.from(fixture.s, 'hex') const DER = transactionBuilder.bip66.encode(r, s) - assert.equal(DER.toString('hex'), fixture.DER) + assert.strictEqual(DER.toString('hex'), fixture.DER) }) }) @@ -1966,8 +1967,8 @@ describe('#TransactionBuilder', () => { const transactionBuilder = new bchjs.TransactionBuilder() const buffer = Buffer.from(fixture.DER, 'hex') const signature = transactionBuilder.bip66.decode(buffer) - assert.equal(signature.r.toString('hex'), fixture.r) - assert.equal(signature.s.toString('hex'), fixture.s) + assert.strictEqual(signature.r.toString('hex'), fixture.r) + assert.strictEqual(signature.s.toString('hex'), fixture.s) }) }) @@ -1975,7 +1976,7 @@ describe('#TransactionBuilder', () => { it(`should bip66 check ${fixture.DER}`, () => { const transactionBuilder = new bchjs.TransactionBuilder() const buffer = Buffer.from(fixture.DER, 'hex') - assert.equal(transactionBuilder.bip66.check(buffer), true) + assert.strictEqual(transactionBuilder.bip66.check(buffer), true) }) }) }) @@ -1987,17 +1988,17 @@ describe('#TransactionBuilder', () => { const obj = {} obj[fixture.type] = fixture.value const encode = transactionBuilder.bip68.encode(obj) - assert.equal(encode, fixture.result) + assert2.equal(encode, fixture.result) }) }) fixtures.bip68.decode.forEach(fixture => { it(`should bip68 decode ${fixture.result}`, () => { const transactionBuilder = new bchjs.TransactionBuilder() - const obj = {} + // const obj = {} const decode = transactionBuilder.bip68.decode(fixture.result) - assert.equal(Object.keys(decode)[0], fixture.type) - assert.deepEqual(decode[Object.keys(decode)[0]], fixture.value) + assert2.equal(Object.keys(decode)[0], fixture.type) + assert2.equal(decode[Object.keys(decode)[0]], fixture.value) }) }) }) @@ -2031,7 +2032,7 @@ describe('#TransactionBuilder', () => { ) const tx = transactionBuilder.build() const hex = tx.toHex() - assert.equal(hex, fixture.hex) + assert.strictEqual(hex, fixture.hex) }) }) }) diff --git a/test/unit/util.js b/test/unit/util.js index 0034874..dda4500 100644 --- a/test/unit/util.js +++ b/test/unit/util.js @@ -20,14 +20,14 @@ describe('#Util', () => { isscript: false } - const resolved = new Promise(r => r({ data: data })) + const resolved = new Promise(resolve => resolve({ data: data })) sandbox.stub(axios, 'get').returns(resolved) bchjs.Util.validateAddress( 'bitcoincash:qpz7qtkuyhrsz4qmnnrvf8gz9zd0u9v7eqsewyk4w5' ) .then(result => { - assert.deepEqual(data, result) + assert.deepStrictEqual(data, result) }) .then(done, done) })