mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
fix(lint): Fixing linting issue
This commit is contained in:
Generated
+531
-646
File diff suppressed because it is too large
Load Diff
+11
-1
@@ -69,10 +69,20 @@
|
|||||||
"nyc": "15.1.0",
|
"nyc": "15.1.0",
|
||||||
"semantic-release": "19.0.5",
|
"semantic-release": "19.0.5",
|
||||||
"sinon": "9.2.2",
|
"sinon": "9.2.2",
|
||||||
"standard": "16.0.4"
|
"standard": "17.1.2"
|
||||||
},
|
},
|
||||||
"apidoc": {
|
"apidoc": {
|
||||||
"title": "bch-js",
|
"title": "bch-js",
|
||||||
"url": "bchjs."
|
"url": "bchjs."
|
||||||
|
},
|
||||||
|
"husky": {
|
||||||
|
"hooks": {
|
||||||
|
"pre-commit": "npm run lint"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"standard": {
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -312,28 +312,28 @@ class Address {
|
|||||||
return {
|
return {
|
||||||
prefix: 'bitcoincash',
|
prefix: 'bitcoincash',
|
||||||
type: 'P2PKH',
|
type: 'P2PKH',
|
||||||
hash: hash,
|
hash,
|
||||||
format: 'legacy'
|
format: 'legacy'
|
||||||
}
|
}
|
||||||
case info.main.versions.scripthash:
|
case info.main.versions.scripthash:
|
||||||
return {
|
return {
|
||||||
prefix: 'bitcoincash',
|
prefix: 'bitcoincash',
|
||||||
type: 'P2SH',
|
type: 'P2SH',
|
||||||
hash: hash,
|
hash,
|
||||||
format: 'legacy'
|
format: 'legacy'
|
||||||
}
|
}
|
||||||
case info.test.versions.public:
|
case info.test.versions.public:
|
||||||
return {
|
return {
|
||||||
prefix: 'bchtest',
|
prefix: 'bchtest',
|
||||||
type: 'P2PKH',
|
type: 'P2PKH',
|
||||||
hash: hash,
|
hash,
|
||||||
format: 'legacy'
|
format: 'legacy'
|
||||||
}
|
}
|
||||||
case info.test.versions.scripthash:
|
case info.test.versions.scripthash:
|
||||||
return {
|
return {
|
||||||
prefix: 'bchtest',
|
prefix: 'bchtest',
|
||||||
type: 'P2SH',
|
type: 'P2SH',
|
||||||
hash: hash,
|
hash,
|
||||||
format: 'legacy'
|
format: 'legacy'
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
+3
-3
@@ -288,7 +288,7 @@ class Blockchain {
|
|||||||
`${this.restURL}blockchain/getBlockHeader`,
|
`${this.restURL}blockchain/getBlockHeader`,
|
||||||
{
|
{
|
||||||
hashes: hash,
|
hashes: hash,
|
||||||
verbose: verbose
|
verbose
|
||||||
},
|
},
|
||||||
this.axiosOptions
|
this.axiosOptions
|
||||||
)
|
)
|
||||||
@@ -644,7 +644,7 @@ class Blockchain {
|
|||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`${this.restURL}blockchain/getTxOut`,
|
`${this.restURL}blockchain/getTxOut`,
|
||||||
{
|
{
|
||||||
txid: txid,
|
txid,
|
||||||
vout: n,
|
vout: n,
|
||||||
mempool: includeMempool
|
mempool: includeMempool
|
||||||
},
|
},
|
||||||
@@ -710,7 +710,7 @@ class Blockchain {
|
|||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`${this.restURL}blockchain/getTxOutProof`,
|
`${this.restURL}blockchain/getTxOutProof`,
|
||||||
{
|
{
|
||||||
txids: txids
|
txids
|
||||||
},
|
},
|
||||||
this.axiosOptions
|
this.axiosOptions
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-5
@@ -1,6 +1,3 @@
|
|||||||
/* eslint no-prototype-builtins: "off" */
|
|
||||||
/* eslint node/no-callback-literal: "off" */
|
|
||||||
|
|
||||||
import BIP39 from 'bip39'
|
import BIP39 from 'bip39'
|
||||||
import randomBytes from 'randombytes'
|
import randomBytes from 'randombytes'
|
||||||
import Bitcoin from '@psf/bitcoincashjs-lib'
|
import Bitcoin from '@psf/bitcoincashjs-lib'
|
||||||
@@ -356,7 +353,7 @@ const _extend = function (dst) {
|
|||||||
const sources = Array.prototype.slice.call(arguments, 1)
|
const sources = Array.prototype.slice.call(arguments, 1)
|
||||||
for (let i = 0; i < sources.length; ++i) {
|
for (let i = 0; i < sources.length; ++i) {
|
||||||
const src = sources[i]
|
const src = sources[i]
|
||||||
for (const p in src) if (src.hasOwnProperty(p)) dst[p] = src[p]
|
for (const p in src) if (Object.prototype.hasOwnProperty.call(src, p)) dst[p] = src[p]
|
||||||
}
|
}
|
||||||
return dst
|
return dst
|
||||||
}
|
}
|
||||||
@@ -503,7 +500,7 @@ const Levenshtein = {
|
|||||||
try {
|
try {
|
||||||
options.progress.call(null, (i * 100.0) / str1.length)
|
options.progress.call(null, (i * 100.0) / str1.length)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return cb(`Progress callback: ${err.toString()}`)
|
return cb(new Error(`Progress callback: ${err.toString()}`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ class RawTransactions {
|
|||||||
url: `${this.restURL}rawtransactions/getRawTransaction`,
|
url: `${this.restURL}rawtransactions/getRawTransaction`,
|
||||||
data: {
|
data: {
|
||||||
txids: txid,
|
txids: txid,
|
||||||
verbose: verbose,
|
verbose,
|
||||||
usrObj // pass user data when making an internal call.
|
usrObj // pass user data when making an internal call.
|
||||||
},
|
},
|
||||||
headers: this.axiosOptions.headers
|
headers: this.axiosOptions.headers
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
import Bitcoin from '@psf/bitcoincashjs-lib'
|
import Bitcoin from '@psf/bitcoincashjs-lib'
|
||||||
/* eslint-disable */
|
import { createRequire } from 'module'
|
||||||
import opcodes from '@psf/bitcoincash-ops' with { type: 'json' }
|
const require = createRequire(import.meta.url)
|
||||||
/* eslint-enable */
|
const opcodes = require('@psf/bitcoincash-ops')
|
||||||
|
|
||||||
class Script {
|
class Script {
|
||||||
constructor () {
|
constructor () {
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ async function loadDependencies () {
|
|||||||
// const BITBOX = new BITBOXSDK({ restURL: "http://localhost:3000/v2/" })
|
// const BITBOX = new BITBOXSDK({ restURL: "http://localhost:3000/v2/" })
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* eslint-disable */
|
const { createRequire } = await import('module')
|
||||||
walletInfo = (await import('./wallet.json', { with: { type: 'json' } })).default
|
const require = createRequire(import.meta.url)
|
||||||
/* eslint-enable */
|
walletInfo = require('./wallet.json')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(
|
console.log(
|
||||||
'Could not open wallet.json. Generate a wallet with create-wallet first.'
|
'Could not open wallet.json. Generate a wallet with create-wallet first.'
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ async function loadDependencies () {
|
|||||||
// const BITBOX = new BITBOXSDK({ restURL: "http://localhost:3000/v2/" })
|
// const BITBOX = new BITBOXSDK({ restURL: "http://localhost:3000/v2/" })
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* eslint-disable */
|
const { createRequire } = await import('module')
|
||||||
walletInfo = (await import('./wallet.json', { with: { type: 'json' } })).default
|
const require = createRequire(import.meta.url)
|
||||||
/* eslint-enable */
|
walletInfo = require('./wallet.json')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(
|
console.log(
|
||||||
'Could not open wallet.json. Generate a wallet with create-wallet first.'
|
'Could not open wallet.json. Generate a wallet with create-wallet first.'
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
tests.
|
tests.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import SLPSDK from '../../../lib/SLP.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
openWallet,
|
openWallet,
|
||||||
sendToken,
|
sendToken,
|
||||||
getTestTokenBalance,
|
getTestTokenBalance,
|
||||||
threeDecimals
|
threeDecimals
|
||||||
}
|
}
|
||||||
|
|
||||||
import SLPSDK from '../../../lib/SLP.js'
|
|
||||||
const slpsdk = new SLPSDK()
|
const slpsdk = new SLPSDK()
|
||||||
|
|
||||||
const testTokenId =
|
const testTokenId =
|
||||||
@@ -20,11 +20,10 @@ const testTokenId =
|
|||||||
// token balance.
|
// token balance.
|
||||||
async function openWallet (filename) {
|
async function openWallet (filename) {
|
||||||
try {
|
try {
|
||||||
// Note: Dynamic imports for JSON files - use createRequire or import with assert
|
// Note: Dynamic imports for JSON files - use createRequire
|
||||||
// For ESM, we need to handle dynamic JSON imports differently
|
const { createRequire } = await import('module')
|
||||||
/* eslint-disable */
|
const require = createRequire(import.meta.url)
|
||||||
const walletInfo = await import(filename, { with: { type: 'json' } }).then(m => m.default)
|
const walletInfo = require(filename)
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
// const walletBalance = await getBalance(walletInfo)
|
// const walletBalance = await getBalance(walletInfo)
|
||||||
// const walletBalance = await slpsdk.Utils.balancesForAddress(
|
// const walletBalance = await slpsdk.Utils.balancesForAddress(
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import assert from 'assert'
|
|||||||
import Bitcoin from '@psf/bitcoincashjs-lib'
|
import Bitcoin from '@psf/bitcoincashjs-lib'
|
||||||
|
|
||||||
// Mocks
|
// Mocks
|
||||||
/* eslint-disable */
|
import { createRequire } from 'module'
|
||||||
import fixtures from './fixtures/address.json' with { type: 'json' }
|
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
// Unit under test (uut)
|
// Unit under test (uut)
|
||||||
import BCHJS from '../../src/bch-js.js'
|
import BCHJS from '../../src/bch-js.js'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const fixtures = require('./fixtures/address.json')
|
||||||
let bchjs
|
let bchjs
|
||||||
|
|
||||||
function flatten (arrays) {
|
function flatten (arrays) {
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
|
|
||||||
// Mocks
|
// Mocks
|
||||||
/* eslint-disable */
|
import { createRequire } from 'module'
|
||||||
import fixtures from './fixtures/bitcoincash.json' with { type: 'json' }
|
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
// Unit under test (uut)
|
// Unit under test (uut)
|
||||||
import BCHJS from '../../src/bch-js.js'
|
import BCHJS from '../../src/bch-js.js'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const fixtures = require('./fixtures/bitcoincash.json')
|
||||||
// const bchjs = new BCHJS()
|
// const bchjs = new BCHJS()
|
||||||
let bchjs
|
let bchjs
|
||||||
|
|
||||||
|
|||||||
+15
-15
@@ -61,7 +61,7 @@ describe('#Blockchain', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should get block by hash', done => {
|
it('should get block by hash', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'post').returns(resolved)
|
sandbox.stub(axios, 'post').returns(resolved)
|
||||||
|
|
||||||
const blockhash =
|
const blockhash =
|
||||||
@@ -130,7 +130,7 @@ describe('#Blockchain', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should get blockchain info', done => {
|
it('should get blockchain info', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.getBlockchainInfo()
|
bchjs.Blockchain.getBlockchainInfo()
|
||||||
@@ -148,7 +148,7 @@ describe('#Blockchain', () => {
|
|||||||
const data = 527810
|
const data = 527810
|
||||||
|
|
||||||
it('should get block count', done => {
|
it('should get block count', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.getBlockCount()
|
bchjs.Blockchain.getBlockCount()
|
||||||
@@ -167,7 +167,7 @@ describe('#Blockchain', () => {
|
|||||||
'000000000000000001d127592d091d4c45062504663c9acab27a1b16c028e3c0'
|
'000000000000000001d127592d091d4c45062504663c9acab27a1b16c028e3c0'
|
||||||
|
|
||||||
it('should get block hash by height', done => {
|
it('should get block hash by height', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.getBlockHash(527810)
|
bchjs.Blockchain.getBlockHash(527810)
|
||||||
@@ -202,7 +202,7 @@ describe('#Blockchain', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should get block header by hash', done => {
|
it('should get block header by hash', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.getBlockHeader(
|
bchjs.Blockchain.getBlockHeader(
|
||||||
@@ -223,7 +223,7 @@ describe('#Blockchain', () => {
|
|||||||
const data = '577528469277.1339'
|
const data = '577528469277.1339'
|
||||||
|
|
||||||
it('should get difficulty', done => {
|
it('should get difficulty', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.getDifficulty()
|
bchjs.Blockchain.getDifficulty()
|
||||||
@@ -241,7 +241,7 @@ describe('#Blockchain', () => {
|
|||||||
const data = 'Transaction not in mempool'
|
const data = 'Transaction not in mempool'
|
||||||
|
|
||||||
it('should get mempool ancestors', done => {
|
it('should get mempool ancestors', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.getMempoolAncestors(
|
bchjs.Blockchain.getMempoolAncestors(
|
||||||
@@ -264,7 +264,7 @@ describe('#Blockchain', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should get mempool descendants', done => {
|
it('should get mempool descendants', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.getMempoolDescendants(
|
bchjs.Blockchain.getMempoolDescendants(
|
||||||
@@ -287,7 +287,7 @@ describe('#Blockchain', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should get mempool entry', done => {
|
it('should get mempool entry', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.getMempoolEntry(
|
bchjs.Blockchain.getMempoolEntry(
|
||||||
@@ -315,7 +315,7 @@ describe('#Blockchain', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should get mempool info', done => {
|
it('should get mempool info', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.getMempoolInfo()
|
bchjs.Blockchain.getMempoolInfo()
|
||||||
@@ -356,7 +356,7 @@ describe('#Blockchain', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should get mempool info', done => {
|
it('should get mempool info', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.getRawMempool()
|
bchjs.Blockchain.getRawMempool()
|
||||||
@@ -452,7 +452,7 @@ describe('#Blockchain', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should get TODO', done => {
|
it('should get TODO', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.preciousBlock()
|
bchjs.Blockchain.preciousBlock()
|
||||||
@@ -470,7 +470,7 @@ describe('#Blockchain', () => {
|
|||||||
const data = 'Cannot prune blocks because node is not in prune mode.'
|
const data = 'Cannot prune blocks because node is not in prune mode.'
|
||||||
|
|
||||||
it('should prune blockchain', done => {
|
it('should prune blockchain', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'post').returns(resolved)
|
sandbox.stub(axios, 'post').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.pruneBlockchain(507)
|
bchjs.Blockchain.pruneBlockchain(507)
|
||||||
@@ -488,7 +488,7 @@ describe('#Blockchain', () => {
|
|||||||
const data = true
|
const data = true
|
||||||
|
|
||||||
it('should verify blockchain', done => {
|
it('should verify blockchain', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.verifyChain(3, 6)
|
bchjs.Blockchain.verifyChain(3, 6)
|
||||||
@@ -506,7 +506,7 @@ describe('#Blockchain', () => {
|
|||||||
const data = "proof must be hexadecimal string (not '')"
|
const data = "proof must be hexadecimal string (not '')"
|
||||||
|
|
||||||
it('should verify utxo proof', done => {
|
it('should verify utxo proof', done => {
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Blockchain.verifyTxOutProof('3')
|
bchjs.Blockchain.verifyTxOutProof('3')
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ describe('#Control', () => {
|
|||||||
relayfee: 0.00001,
|
relayfee: 0.00001,
|
||||||
errors: ''
|
errors: ''
|
||||||
}
|
}
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Control.getNetworkInfo()
|
bchjs.Control.getNetworkInfo()
|
||||||
@@ -47,7 +47,7 @@ describe('#Control', () => {
|
|||||||
chunks_free: 1
|
chunks_free: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Control.getMemoryInfo()
|
bchjs.Control.getMemoryInfo()
|
||||||
|
|||||||
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
/* eslint-disable */
|
import { createRequire } from 'module'
|
||||||
import fixtures from './fixtures/crypto.json' with { type: 'json' }
|
|
||||||
/* eslint-enable */
|
|
||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import BCHJS from '../../src/bch-js.js'
|
import BCHJS from '../../src/bch-js.js'
|
||||||
const bchjs = new BCHJS()
|
|
||||||
import { Buffer } from 'safe-buffer'
|
import { Buffer } from 'safe-buffer'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const fixtures = require('./fixtures/crypto.json')
|
||||||
|
const bchjs = new BCHJS()
|
||||||
|
|
||||||
describe('#Crypto', () => {
|
describe('#Crypto', () => {
|
||||||
describe('#sha256', () => {
|
describe('#sha256', () => {
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ import assert from 'assert'
|
|||||||
import { Buffer } from 'safe-buffer'
|
import { Buffer } from 'safe-buffer'
|
||||||
|
|
||||||
// Mocks
|
// Mocks
|
||||||
/* eslint-disable */
|
import { createRequire } from 'module'
|
||||||
import fixtures from './fixtures/ecpair.json' with { type: 'json' }
|
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
// Unit under test (uut)
|
// Unit under test (uut)
|
||||||
import BCHJS from '../../src/bch-js.js'
|
import BCHJS from '../../src/bch-js.js'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const fixtures = require('./fixtures/ecpair.json')
|
||||||
// const bchjs = new BCHJS()
|
// const bchjs = new BCHJS()
|
||||||
let bchjs
|
let bchjs
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ describe('#Generating', () => {
|
|||||||
|
|
||||||
it('should generate', done => {
|
it('should generate', done => {
|
||||||
const data = []
|
const data = []
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'post').returns(resolved)
|
sandbox.stub(axios, 'post').returns(resolved)
|
||||||
|
|
||||||
bchjs.Generating.generateToAddress(
|
bchjs.Generating.generateToAddress(
|
||||||
|
|||||||
+4
-4
@@ -3,13 +3,13 @@ import assert from 'assert'
|
|||||||
import { Buffer } from 'safe-buffer'
|
import { Buffer } from 'safe-buffer'
|
||||||
|
|
||||||
// Mocks
|
// Mocks
|
||||||
/* eslint-disable */
|
import { createRequire } from 'module'
|
||||||
import fixtures from './fixtures/hdnode.json' with { type: 'json' }
|
// const slpFixtures = require('./fixtures/slp/address.json')
|
||||||
/* eslint-enable */
|
|
||||||
// import slpFixtures from './fixtures/slp/address.json' with { type: 'json' }
|
|
||||||
|
|
||||||
// Unit under test (uut)
|
// Unit under test (uut)
|
||||||
import BCHJS from '../../src/bch-js.js'
|
import BCHJS from '../../src/bch-js.js'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const fixtures = require('./fixtures/hdnode.json')
|
||||||
let bchjs
|
let bchjs
|
||||||
|
|
||||||
describe('#HDNode', () => {
|
describe('#HDNode', () => {
|
||||||
|
|||||||
+4
-4
@@ -30,7 +30,7 @@ describe('#Mining', () => {
|
|||||||
sigops: 2
|
sigops: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Mining.getBlockTemplate('')
|
bchjs.Mining.getBlockTemplate('')
|
||||||
@@ -59,7 +59,7 @@ describe('#Mining', () => {
|
|||||||
chain: 'main'
|
chain: 'main'
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Mining.getMiningInfo()
|
bchjs.Mining.getMiningInfo()
|
||||||
@@ -78,7 +78,7 @@ describe('#Mining', () => {
|
|||||||
it('should get network hashps', done => {
|
it('should get network hashps', done => {
|
||||||
const data = 3586365937646890000
|
const data = 3586365937646890000
|
||||||
|
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Mining.getNetworkHashps()
|
bchjs.Mining.getNetworkHashps()
|
||||||
@@ -98,7 +98,7 @@ describe('#Mining', () => {
|
|||||||
it('should TODO', done => {
|
it('should TODO', done => {
|
||||||
const data = {}
|
const data = {}
|
||||||
|
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'post').returns(resolved)
|
sandbox.stub(axios, 'post').returns(resolved)
|
||||||
|
|
||||||
bchjs.Mining.submitBlock()
|
bchjs.Mining.submitBlock()
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/* eslint-disable */
|
import { createRequire } from 'module'
|
||||||
import fixtures from './fixtures/mnemonic.json' with { type: 'json' }
|
|
||||||
/* eslint-enable */
|
|
||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import BCHJS from '../../src/bch-js.js'
|
import BCHJS from '../../src/bch-js.js'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const fixtures = require('./fixtures/mnemonic.json')
|
||||||
const bchjs = new BCHJS()
|
const bchjs = new BCHJS()
|
||||||
|
|
||||||
describe('#Mnemonic', () => {
|
describe('#Mnemonic', () => {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ describe('#RawTransactions', () => {
|
|||||||
vout: []
|
vout: []
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.RawTransactions.decodeRawTransaction('02000000000000000000')
|
bchjs.RawTransactions.decodeRawTransaction('02000000000000000000')
|
||||||
@@ -68,7 +68,7 @@ describe('#RawTransactions', () => {
|
|||||||
p2sh: 'bitcoincash:prswx5965nfumux9qng5kj8hw603vcne7q08t8c6jp'
|
p2sh: 'bitcoincash:prswx5965nfumux9qng5kj8hw603vcne7q08t8c6jp'
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
const result = await bchjs.RawTransactions.decodeScript(
|
const result = await bchjs.RawTransactions.decodeScript(
|
||||||
@@ -89,7 +89,7 @@ describe('#RawTransactions', () => {
|
|||||||
const data =
|
const data =
|
||||||
'020000000160d663961c63c7f0a07f22ec07b8f55b3935bfdbed8b1d8454916e8932fbf109010000006b4830450221008479fab4cfdcb111833d250a43f98ac26d43272b7a29cb1b9a0491eae5c44b3502203448b17253632395c29a7d62058bbfe93efb20fc8636ba6837002d464195aec04121029123258f7cdcd45b864066bcaa9b71f24d5ed1fa1dd36eaf107d8432b5014658ffffffff016d180000000000001976a91479d3297d1823149f4ec61df31d19f2fad5390c0288ac00000000'
|
'020000000160d663961c63c7f0a07f22ec07b8f55b3935bfdbed8b1d8454916e8932fbf109010000006b4830450221008479fab4cfdcb111833d250a43f98ac26d43272b7a29cb1b9a0491eae5c44b3502203448b17253632395c29a7d62058bbfe93efb20fc8636ba6837002d464195aec04121029123258f7cdcd45b864066bcaa9b71f24d5ed1fa1dd36eaf107d8432b5014658ffffffff016d180000000000001976a91479d3297d1823149f4ec61df31d19f2fad5390c0288ac00000000'
|
||||||
|
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.RawTransactions.getRawTransaction(
|
bchjs.RawTransactions.getRawTransaction(
|
||||||
@@ -110,7 +110,7 @@ describe('#RawTransactions', () => {
|
|||||||
it('should send single raw transaction', async () => {
|
it('should send single raw transaction', async () => {
|
||||||
const data = 'Error: transaction already in block chain'
|
const data = 'Error: transaction already in block chain'
|
||||||
|
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
const result = await bchjs.RawTransactions.sendRawTransaction(
|
const result = await bchjs.RawTransactions.sendRawTransaction(
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ import assert from 'assert'
|
|||||||
import { Buffer } from 'safe-buffer'
|
import { Buffer } from 'safe-buffer'
|
||||||
|
|
||||||
// Mocks
|
// Mocks
|
||||||
/* eslint-disable */
|
import { createRequire } from 'module'
|
||||||
import fixtures from './fixtures/script.json' with { type: 'json' }
|
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
// Unit under test (uut)
|
// Unit under test (uut)
|
||||||
import BCHJS from '../../src/bch-js.js'
|
import BCHJS from '../../src/bch-js.js'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const fixtures = require('./fixtures/script.json')
|
||||||
let bchjs
|
let bchjs
|
||||||
|
|
||||||
describe('#Script', () => {
|
describe('#Script', () => {
|
||||||
@@ -440,8 +440,8 @@ describe('#Script', () => {
|
|||||||
Buffer.from(fixture.hex, 'hex')
|
Buffer.from(fixture.hex, 'hex')
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
redeemScriptSig: redeemScriptSig,
|
redeemScriptSig,
|
||||||
redeemScript: redeemScript
|
redeemScript
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
|
|
||||||
import BCHJS from '../../src/bch-js.js'
|
import BCHJS from '../../src/bch-js.js'
|
||||||
|
|
||||||
|
import { createRequire } from 'module'
|
||||||
// import SLP from "../../src/slp/slp.js"
|
// import SLP from "../../src/slp/slp.js"
|
||||||
// const SLP = new slp({ restURL: "http://fakeurl.com/" })
|
// const SLP = new slp({ restURL: "http://fakeurl.com/" })
|
||||||
let slp
|
let slp
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
/* eslint-disable */
|
const fixtures = require('./fixtures/slp/address.json')
|
||||||
import fixtures from './fixtures/slp/address.json' with { type: 'json' }
|
|
||||||
/* eslint-enable */
|
|
||||||
// const axios = require("axios")
|
// const axios = require("axios")
|
||||||
// const sinon = require("sinon")
|
// const sinon = require("sinon")
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
|
|
||||||
/* eslint-disable */
|
import { createRequire } from 'module'
|
||||||
import fixtures from './fixtures/slp/ecpair.json' with { type: 'json' }
|
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
import BCHJS from '../../src/bch-js.js'
|
import BCHJS from '../../src/bch-js.js'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const fixtures = require('./fixtures/slp/ecpair.json')
|
||||||
let slp
|
let slp
|
||||||
|
|
||||||
// const SLP = require("../../src/slp/slp")
|
// const SLP = require("../../src/slp/slp")
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/* eslint-disable */
|
import { createRequire } from 'module'
|
||||||
import fixtures from './fixtures/transaction-builder.json' with { type: 'json' }
|
|
||||||
/* eslint-enable */
|
|
||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import chai from 'chai'
|
import chai from 'chai'
|
||||||
const { assert: assert2 } = chai
|
|
||||||
import BCHJS from '../../src/bch-js.js'
|
import BCHJS from '../../src/bch-js.js'
|
||||||
const bchjs = new BCHJS()
|
|
||||||
import { Buffer } from 'safe-buffer'
|
import { Buffer } from 'safe-buffer'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const fixtures = require('./fixtures/transaction-builder.json')
|
||||||
|
const { assert: assert2 } = chai
|
||||||
|
const bchjs = new BCHJS()
|
||||||
|
|
||||||
describe('#TransactionBuilder', () => {
|
describe('#TransactionBuilder', () => {
|
||||||
describe('#hashTypes', () => {
|
describe('#hashTypes', () => {
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ describe('#Util', () => {
|
|||||||
isscript: false
|
isscript: false
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolved = new Promise(resolve => resolve({ data: data }))
|
const resolved = new Promise(resolve => resolve({ data }))
|
||||||
sandbox.stub(axios, 'get').returns(resolved)
|
sandbox.stub(axios, 'get').returns(resolved)
|
||||||
|
|
||||||
bchjs.Util.validateAddress(
|
bchjs.Util.validateAddress(
|
||||||
|
|||||||
Reference in New Issue
Block a user