@psf/bch-js 6.8.3 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +10 -28
- package/fix-docs-contrast.sh +38 -0
- package/package.json +38 -47
- package/src/address.js +12 -23
- package/src/bch-js.js +81 -48
- package/src/bitcoincash.js +10 -11
- package/src/blockchain.js +57 -68
- package/src/control.js +11 -22
- package/src/crypto.js +3 -3
- package/src/dsproof.js +6 -17
- package/src/ecash.js +1 -1
- package/src/ecpair.js +3 -3
- package/src/electrumx.js +32 -44
- package/src/encryption.js +8 -17
- package/src/generating.js +8 -19
- package/src/hdnode.js +5 -5
- package/src/mining.js +11 -22
- package/src/mnemonic.js +8 -11
- package/src/price.js +7 -108
- package/src/psf-slp-indexer.js +21 -32
- package/src/raw-transactions.js +22 -35
- package/src/schnorr.js +5 -16
- package/src/script.js +4 -2
- package/src/slp/address.js +4 -4
- package/src/slp/ecpair.js +4 -4
- package/src/slp/nft1.js +6 -6
- package/src/slp/slp.js +11 -22
- package/src/slp/tokentype1.js +11 -22
- package/src/slp/utils.js +9 -19
- package/src/transaction-builder.js +5 -5
- package/src/transaction.js +5 -5
- package/src/util.js +5 -98
- package/src/utxo.js +6 -6
- package/test/e2e/bch-js-e2e-tests.js +4 -3
- package/test/e2e/ipfs/ipfs-e2e.js +8 -2
- package/test/e2e/rate-limits/anonymous-rate-limits.js +5 -4
- package/test/e2e/rate-limits/basic-auth-rate-limits.js +4 -3
- package/test/e2e/rate-limits/free-rate-limits.js +4 -3
- package/test/e2e/rate-limits/full-node-rate-limits.js +4 -3
- package/test/e2e/rate-limits/indexer-rate-limits.js +4 -3
- package/test/e2e/send-raw-transaction-bulk/sendrawtransaction.js +28 -18
- package/test/e2e/send-raw-transaction-single/sendrawtransaction.js +28 -18
- package/test/e2e/send-token/send-token.js +4 -4
- package/test/e2e/util/e2e-util.js +6 -3
- package/test/e2e/utxo/unsynced-indexer.js +1 -1
- package/test/integration/blockchain.js +5 -5
- package/test/integration/control.js +2 -2
- package/test/integration/{chains/bchn/dsproof.js → dsproof.js} +6 -2
- package/test/integration/electrumx.js +5 -12
- package/test/integration/price.js +3 -39
- package/test/integration/{chains/bchn/psf-slp-indexer.integration.js → psf-slp-indexer.integration.js} +5 -6
- package/test/integration/rawtransaction.js +39 -5
- package/test/integration/slp.js +147 -5
- package/test/integration/transaction-integration.js +27 -2
- package/test/integration/{chains/bchn/utxo-integration.js → utxo-integration.js} +3 -2
- package/test/unit/address.js +7 -4
- package/test/unit/bitcoin-cash.js +5 -3
- package/test/unit/blockchain.js +23 -22
- package/test/unit/control.js +6 -6
- package/test/unit/crypto.js +5 -3
- package/test/unit/dsproof.js +5 -4
- package/test/unit/ecash.js +3 -2
- package/test/unit/ecpairs.js +6 -4
- package/test/unit/electrumx.js +7 -7
- package/test/unit/encryption.js +6 -5
- package/test/unit/fixtures/bitcore-mock.js +1 -1
- package/test/unit/fixtures/block-mock.js +1 -1
- package/test/unit/fixtures/blockchain-mock.js +1 -1
- package/test/unit/fixtures/dsproof-mock.js +1 -1
- package/test/unit/fixtures/electrumx-mock.js +1 -1
- package/test/unit/fixtures/encryption-mock.js +1 -1
- package/test/unit/fixtures/ipfs-mock.js +1 -1
- package/test/unit/fixtures/openbazaar-mock.js +1 -1
- package/test/unit/fixtures/price-mocks.js +1 -1
- package/test/unit/fixtures/psf-slp-indexer-mock.js +1 -1
- package/test/unit/fixtures/rawtransaction-mock.js +1 -1
- package/test/unit/fixtures/slp/mock-utils.js +1 -1
- package/test/unit/fixtures/transaction-mock.js +1 -1
- package/test/unit/fixtures/utxo-mocks.js +1 -1
- package/test/unit/generating.js +5 -5
- package/test/unit/hdnode.js +6 -4
- package/test/unit/mining.js +8 -8
- package/test/unit/mnemonic.js +4 -2
- package/test/unit/price.js +5 -14
- package/test/unit/psf-slp-indexer.js +7 -7
- package/test/unit/raw-tranactions.js +14 -13
- package/test/unit/scripts.js +8 -6
- package/test/unit/slp-address.js +6 -4
- package/test/unit/slp-ecpair.js +5 -3
- package/test/unit/slp-nft1.js +7 -6
- package/test/unit/slp-tokentype1.js +7 -6
- package/test/unit/slp-utils.js +8 -7
- package/test/unit/transaction-builder.js +7 -4
- package/test/unit/transaction-unit.js +5 -4
- package/test/unit/util.js +11 -32
- package/test/unit/utxo-unit.js +6 -5
- package/test/unit/x402.js +193 -0
- package/test/integration/chains/abc/psf-slp-indexer-integration.js +0 -38
- package/test/integration/chains/abc/rawtransaction.js +0 -73
- package/test/integration/chains/abc/utxo-integration.js +0 -38
- package/test/integration/chains/bchn/rawtransaction.js +0 -71
- package/test/integration/chains/bchn/slp.js +0 -301
- package/test/integration/chains/bchn/transaction-integration.js +0 -37
- package/test/integration/chains/bchn/util.js +0 -103
- package/test/integration/chains/testnet/blockchain.js +0 -260
- package/test/integration/chains/testnet/control.js +0 -32
- package/test/integration/chains/testnet/electrumx.js +0 -376
- package/test/integration/chains/testnet/rawtransaction.js +0 -296
- package/test/integration/chains/testnet/slp.js +0 -172
- package/test/integration/chains/testnet/test-free-tier.sh +0 -9
- package/test/integration/chains/testnet/util.js +0 -109
package/test/unit/blockchain.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import chai from 'chai'
|
|
3
|
+
import axios from 'axios'
|
|
4
|
+
import BCHJS from '../../src/bch-js.js'
|
|
5
|
+
import sinon from 'sinon'
|
|
6
|
+
|
|
7
|
+
import mockData from './fixtures/blockchain-mock.js'
|
|
8
|
+
const { assert: assert2 } = chai
|
|
5
9
|
const bchjs = new BCHJS()
|
|
6
|
-
const sinon = require('sinon')
|
|
7
|
-
|
|
8
|
-
const mockData = require('./fixtures/blockchain-mock')
|
|
9
10
|
|
|
10
11
|
describe('#Blockchain', () => {
|
|
11
12
|
describe('#getBestBlockHash', () => {
|
|
@@ -60,7 +61,7 @@ describe('#Blockchain', () => {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
it('should get block by hash', done => {
|
|
63
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
64
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
64
65
|
sandbox.stub(axios, 'post').returns(resolved)
|
|
65
66
|
|
|
66
67
|
const blockhash =
|
|
@@ -129,7 +130,7 @@ describe('#Blockchain', () => {
|
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
it('should get blockchain info', done => {
|
|
132
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
133
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
133
134
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
134
135
|
|
|
135
136
|
bchjs.Blockchain.getBlockchainInfo()
|
|
@@ -147,7 +148,7 @@ describe('#Blockchain', () => {
|
|
|
147
148
|
const data = 527810
|
|
148
149
|
|
|
149
150
|
it('should get block count', done => {
|
|
150
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
151
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
151
152
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
152
153
|
|
|
153
154
|
bchjs.Blockchain.getBlockCount()
|
|
@@ -166,7 +167,7 @@ describe('#Blockchain', () => {
|
|
|
166
167
|
'000000000000000001d127592d091d4c45062504663c9acab27a1b16c028e3c0'
|
|
167
168
|
|
|
168
169
|
it('should get block hash by height', done => {
|
|
169
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
170
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
170
171
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
171
172
|
|
|
172
173
|
bchjs.Blockchain.getBlockHash(527810)
|
|
@@ -201,7 +202,7 @@ describe('#Blockchain', () => {
|
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
it('should get block header by hash', done => {
|
|
204
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
205
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
205
206
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
206
207
|
|
|
207
208
|
bchjs.Blockchain.getBlockHeader(
|
|
@@ -222,7 +223,7 @@ describe('#Blockchain', () => {
|
|
|
222
223
|
const data = '577528469277.1339'
|
|
223
224
|
|
|
224
225
|
it('should get difficulty', done => {
|
|
225
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
226
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
226
227
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
227
228
|
|
|
228
229
|
bchjs.Blockchain.getDifficulty()
|
|
@@ -240,7 +241,7 @@ describe('#Blockchain', () => {
|
|
|
240
241
|
const data = 'Transaction not in mempool'
|
|
241
242
|
|
|
242
243
|
it('should get mempool ancestors', done => {
|
|
243
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
244
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
244
245
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
245
246
|
|
|
246
247
|
bchjs.Blockchain.getMempoolAncestors(
|
|
@@ -263,7 +264,7 @@ describe('#Blockchain', () => {
|
|
|
263
264
|
}
|
|
264
265
|
|
|
265
266
|
it('should get mempool descendants', done => {
|
|
266
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
267
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
267
268
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
268
269
|
|
|
269
270
|
bchjs.Blockchain.getMempoolDescendants(
|
|
@@ -286,7 +287,7 @@ describe('#Blockchain', () => {
|
|
|
286
287
|
}
|
|
287
288
|
|
|
288
289
|
it('should get mempool entry', done => {
|
|
289
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
290
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
290
291
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
291
292
|
|
|
292
293
|
bchjs.Blockchain.getMempoolEntry(
|
|
@@ -314,7 +315,7 @@ describe('#Blockchain', () => {
|
|
|
314
315
|
}
|
|
315
316
|
|
|
316
317
|
it('should get mempool info', done => {
|
|
317
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
318
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
318
319
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
319
320
|
|
|
320
321
|
bchjs.Blockchain.getMempoolInfo()
|
|
@@ -355,7 +356,7 @@ describe('#Blockchain', () => {
|
|
|
355
356
|
}
|
|
356
357
|
|
|
357
358
|
it('should get mempool info', done => {
|
|
358
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
359
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
359
360
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
360
361
|
|
|
361
362
|
bchjs.Blockchain.getRawMempool()
|
|
@@ -451,7 +452,7 @@ describe('#Blockchain', () => {
|
|
|
451
452
|
}
|
|
452
453
|
|
|
453
454
|
it('should get TODO', done => {
|
|
454
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
455
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
455
456
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
456
457
|
|
|
457
458
|
bchjs.Blockchain.preciousBlock()
|
|
@@ -469,7 +470,7 @@ describe('#Blockchain', () => {
|
|
|
469
470
|
const data = 'Cannot prune blocks because node is not in prune mode.'
|
|
470
471
|
|
|
471
472
|
it('should prune blockchain', done => {
|
|
472
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
473
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
473
474
|
sandbox.stub(axios, 'post').returns(resolved)
|
|
474
475
|
|
|
475
476
|
bchjs.Blockchain.pruneBlockchain(507)
|
|
@@ -487,7 +488,7 @@ describe('#Blockchain', () => {
|
|
|
487
488
|
const data = true
|
|
488
489
|
|
|
489
490
|
it('should verify blockchain', done => {
|
|
490
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
491
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
491
492
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
492
493
|
|
|
493
494
|
bchjs.Blockchain.verifyChain(3, 6)
|
|
@@ -505,7 +506,7 @@ describe('#Blockchain', () => {
|
|
|
505
506
|
const data = "proof must be hexadecimal string (not '')"
|
|
506
507
|
|
|
507
508
|
it('should verify utxo proof', done => {
|
|
508
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
509
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
509
510
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
510
511
|
|
|
511
512
|
bchjs.Blockchain.verifyTxOutProof('3')
|
package/test/unit/control.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import axios from 'axios'
|
|
3
|
+
import BCHJS from '../../src/bch-js.js'
|
|
4
|
+
import sinon from 'sinon'
|
|
4
5
|
const bchjs = new BCHJS()
|
|
5
|
-
const sinon = require('sinon')
|
|
6
6
|
|
|
7
7
|
describe('#Control', () => {
|
|
8
8
|
let sandbox
|
|
@@ -24,7 +24,7 @@ describe('#Control', () => {
|
|
|
24
24
|
relayfee: 0.00001,
|
|
25
25
|
errors: ''
|
|
26
26
|
}
|
|
27
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
27
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
28
28
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
29
29
|
|
|
30
30
|
bchjs.Control.getNetworkInfo()
|
|
@@ -47,7 +47,7 @@ describe('#Control', () => {
|
|
|
47
47
|
chunks_free: 1
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
50
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
51
51
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
52
52
|
|
|
53
53
|
bchjs.Control.getMemoryInfo()
|
package/test/unit/crypto.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { createRequire } from 'module'
|
|
2
|
+
import assert from 'assert'
|
|
3
|
+
import BCHJS from '../../src/bch-js.js'
|
|
4
|
+
import { Buffer } from 'safe-buffer'
|
|
5
|
+
const require = createRequire(import.meta.url)
|
|
1
6
|
const fixtures = require('./fixtures/crypto.json')
|
|
2
|
-
const assert = require('assert')
|
|
3
|
-
const BCHJS = require('../../src/bch-js')
|
|
4
7
|
const bchjs = new BCHJS()
|
|
5
|
-
const Buffer = require('safe-buffer').Buffer
|
|
6
8
|
|
|
7
9
|
describe('#Crypto', () => {
|
|
8
10
|
describe('#sha256', () => {
|
package/test/unit/dsproof.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Public npm libraries
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import chai from 'chai'
|
|
3
|
+
import sinon from 'sinon'
|
|
4
4
|
|
|
5
5
|
// Unit under test (uut)
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import BCHJS from '../../src/bch-js.js'
|
|
7
|
+
import mockData from './fixtures/dsproof-mock.js'
|
|
8
|
+
const { assert } = chai
|
|
8
9
|
|
|
9
10
|
let bchjs
|
|
10
11
|
const txid = 'ee0df780b58f6f24467605b2589c44c3a50fc849fb8f91b89669a4ae0d86bc7e'
|
package/test/unit/ecash.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
// Global npm libraries
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import chai from 'chai'
|
|
7
|
+
import Ecash from '../../src/ecash.js'
|
|
8
|
+
const { assert } = chai
|
|
8
9
|
const uut = new Ecash()
|
|
9
10
|
|
|
10
11
|
describe('#eCash', () => {
|
package/test/unit/ecpairs.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// Public npm libraries.
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import assert from 'assert'
|
|
3
|
+
import { Buffer } from 'safe-buffer'
|
|
4
4
|
|
|
5
5
|
// Mocks
|
|
6
|
-
|
|
6
|
+
import { createRequire } from 'module'
|
|
7
7
|
|
|
8
8
|
// Unit under test (uut)
|
|
9
|
-
|
|
9
|
+
import BCHJS from '../../src/bch-js.js'
|
|
10
|
+
const require = createRequire(import.meta.url)
|
|
11
|
+
const fixtures = require('./fixtures/ecpair.json')
|
|
10
12
|
// const bchjs = new BCHJS()
|
|
11
13
|
let bchjs
|
|
12
14
|
|
package/test/unit/electrumx.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const sinon = require('sinon')
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
import axios from 'axios'
|
|
3
|
+
import sinon from 'sinon'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
const bchjs = new BCHJS()
|
|
5
|
+
import BCHJS from '../../src/bch-js.js'
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
import mockData from './fixtures/electrumx-mock.js'
|
|
8
|
+
const assert = chai.assert
|
|
9
|
+
const bchjs = new BCHJS()
|
|
10
10
|
|
|
11
11
|
describe('#ElectrumX', () => {
|
|
12
12
|
let sandbox
|
package/test/unit/encryption.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
import sinon from 'sinon'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import BCHJS from '../../src/bch-js.js'
|
|
5
|
+
|
|
6
|
+
import mockData from './fixtures/encryption-mock.js'
|
|
7
|
+
const { assert } = chai
|
|
5
8
|
// const bchjs = new BCHJS()
|
|
6
9
|
let bchjs
|
|
7
10
|
|
|
8
|
-
const mockData = require('./fixtures/encryption-mock')
|
|
9
|
-
|
|
10
11
|
describe('#Encryption', () => {
|
|
11
12
|
let sandbox
|
|
12
13
|
|
|
@@ -77,7 +77,7 @@ const tx = {
|
|
|
77
77
|
'0200000001ac1e2e38764f9b81f3ff4317b4bd1a381dbdf311277a736f375d4ce217d3095f010000006a473044022000dd11c41a472f2e54348db996e60864d489429f12d1e044d49ff600b880c9590220715a926404bb0e2731a3795afb341ec1dad3f84ead7d27cd31fcc59abb14738c4121038476128287ac37c7a3cf7e8625fd5f024db1bc3d8e37395abe7bf42fda78d0d9ffffffff02e8030000000000001976a9142fe2c4c5ef359bb2fe1a849f891cecffbcfb4f7788acb0b40000000000001976a9142dbf5e1804c39a497b908c876097d63210c8490288ac00000000'
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
export default {
|
|
81
81
|
balance,
|
|
82
82
|
utxo,
|
|
83
83
|
tx
|
package/test/unit/generating.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Public npm libraries
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import assert from 'assert'
|
|
3
|
+
import axios from 'axios'
|
|
4
|
+
import sinon from 'sinon'
|
|
5
5
|
|
|
6
6
|
// Unit under test (uut)
|
|
7
|
-
|
|
7
|
+
import BCHJS from '../../src/bch-js.js'
|
|
8
8
|
// const bchjs = new BCHJS()
|
|
9
9
|
let bchjs
|
|
10
10
|
|
|
@@ -20,7 +20,7 @@ describe('#Generating', () => {
|
|
|
20
20
|
|
|
21
21
|
it('should generate', done => {
|
|
22
22
|
const data = []
|
|
23
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
23
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
24
24
|
sandbox.stub(axios, 'post').returns(resolved)
|
|
25
25
|
|
|
26
26
|
bchjs.Generating.generateToAddress(
|
package/test/unit/hdnode.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// Public npm libraries
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import assert from 'assert'
|
|
3
|
+
import { Buffer } from 'safe-buffer'
|
|
4
4
|
|
|
5
5
|
// Mocks
|
|
6
|
-
|
|
6
|
+
import { createRequire } from 'module'
|
|
7
7
|
// const slpFixtures = require('./fixtures/slp/address.json')
|
|
8
8
|
|
|
9
9
|
// Unit under test (uut)
|
|
10
|
-
|
|
10
|
+
import BCHJS from '../../src/bch-js.js'
|
|
11
|
+
const require = createRequire(import.meta.url)
|
|
12
|
+
const fixtures = require('./fixtures/hdnode.json')
|
|
11
13
|
let bchjs
|
|
12
14
|
|
|
13
15
|
describe('#HDNode', () => {
|
package/test/unit/mining.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Public npm libraries
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import assert from 'assert'
|
|
3
|
+
import axios from 'axios'
|
|
4
|
+
import sinon from 'sinon'
|
|
5
5
|
|
|
6
6
|
// Unit under test (uut)
|
|
7
|
-
|
|
7
|
+
import BCHJS from '../../src/bch-js.js'
|
|
8
8
|
let bchjs
|
|
9
9
|
|
|
10
10
|
describe('#Mining', () => {
|
|
@@ -30,7 +30,7 @@ describe('#Mining', () => {
|
|
|
30
30
|
sigops: 2
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
33
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
34
34
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
35
35
|
|
|
36
36
|
bchjs.Mining.getBlockTemplate('')
|
|
@@ -59,7 +59,7 @@ describe('#Mining', () => {
|
|
|
59
59
|
chain: 'main'
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
62
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
63
63
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
64
64
|
|
|
65
65
|
bchjs.Mining.getMiningInfo()
|
|
@@ -78,7 +78,7 @@ describe('#Mining', () => {
|
|
|
78
78
|
it('should get network hashps', done => {
|
|
79
79
|
const data = 3586365937646890000
|
|
80
80
|
|
|
81
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
81
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
82
82
|
sandbox.stub(axios, 'get').returns(resolved)
|
|
83
83
|
|
|
84
84
|
bchjs.Mining.getNetworkHashps()
|
|
@@ -98,7 +98,7 @@ describe('#Mining', () => {
|
|
|
98
98
|
it('should TODO', done => {
|
|
99
99
|
const data = {}
|
|
100
100
|
|
|
101
|
-
const resolved = new Promise(resolve => resolve({ data
|
|
101
|
+
const resolved = new Promise(resolve => resolve({ data }))
|
|
102
102
|
sandbox.stub(axios, 'post').returns(resolved)
|
|
103
103
|
|
|
104
104
|
bchjs.Mining.submitBlock()
|
package/test/unit/mnemonic.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { createRequire } from 'module'
|
|
2
|
+
import assert from 'assert'
|
|
3
|
+
import BCHJS from '../../src/bch-js.js'
|
|
4
|
+
const require = createRequire(import.meta.url)
|
|
1
5
|
const fixtures = require('./fixtures/mnemonic.json')
|
|
2
|
-
const assert = require('assert')
|
|
3
|
-
const BCHJS = require('../../src/bch-js')
|
|
4
6
|
const bchjs = new BCHJS()
|
|
5
7
|
|
|
6
8
|
describe('#Mnemonic', () => {
|
package/test/unit/price.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
import BCHJS from '../../src/bch-js.js'
|
|
3
|
+
import sinon from 'sinon'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import mockDataLib from './fixtures/price-mocks.js'
|
|
6
|
+
const { assert } = chai
|
|
6
7
|
let mockData
|
|
7
8
|
|
|
8
9
|
describe('#price', () => {
|
|
@@ -57,16 +58,6 @@ describe('#price', () => {
|
|
|
57
58
|
})
|
|
58
59
|
})
|
|
59
60
|
|
|
60
|
-
describe('#getBchaUsd', () => {
|
|
61
|
-
it('should get the USD price of BCHA', async () => {
|
|
62
|
-
sandbox.stub(bchjs.Price.axios, 'get').resolves({ data: { usd: 18.87 } })
|
|
63
|
-
|
|
64
|
-
const result = await bchjs.Price.getBchaUsd()
|
|
65
|
-
// console.log(result)
|
|
66
|
-
|
|
67
|
-
assert.isNumber(result)
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
61
|
describe('#getBchUsd', () => {
|
|
71
62
|
it('should get the USD price of BCH', async () => {
|
|
72
63
|
sandbox.stub(bchjs.Price.axios, 'get').resolves({ data: { usd: 510.39 } })
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const sinon = require('sinon')
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
import axios from 'axios'
|
|
3
|
+
import sinon from 'sinon'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
const bchjs = new BCHJS()
|
|
5
|
+
import BCHJS from '../../src/bch-js.js'
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
import mockData from './fixtures/psf-slp-indexer-mock.js'
|
|
8
|
+
const assert = chai.assert
|
|
9
|
+
const bchjs = new BCHJS()
|
|
10
10
|
|
|
11
11
|
describe('#PsfSlpIndexer', () => {
|
|
12
12
|
let sandbox
|