psffpp 1.0.1

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.
@@ -0,0 +1,372 @@
1
+ /*
2
+ Unit tests for the main index.js library file.
3
+ */
4
+
5
+ // npm libraries
6
+ const assert = require('chai').assert
7
+ const sinon = require('sinon')
8
+ const cloneDeep = require('lodash.clonedeep')
9
+ const SlpWallet = require('minimal-slp-wallet')
10
+
11
+ // Mocking data libraries.
12
+
13
+ // Local libraries
14
+ const MultisigApproval = require('../../index')
15
+ const mockDataLib = require('./mocks/main-index-mocks')
16
+
17
+ describe('#MultisigApproval.js', () => {
18
+ let sandbox
19
+ let mockData
20
+ let uut
21
+ let wallet
22
+
23
+ before(async () => {
24
+ wallet = new SlpWallet(undefined, { interface: 'consumer-api' })
25
+ await wallet.walletInfoPromise
26
+ })
27
+
28
+ beforeEach(() => {
29
+ // Restore the sandbox before each test.
30
+ sandbox = sinon.createSandbox()
31
+
32
+ // Clone the mock data.
33
+ mockData = cloneDeep(mockDataLib)
34
+
35
+ uut = new MultisigApproval({ wallet })
36
+ })
37
+
38
+ afterEach(() => sandbox.restore())
39
+
40
+ describe('#constructor', () => {
41
+ it('should throw an error if wallet is not passed', () => {
42
+ try {
43
+ uut = new MultisigApproval()
44
+
45
+ assert.fail('Unexpected result')
46
+ } catch (err) {
47
+ assert.include(err.message, 'Instance of minimal-slp-wallet must be passed in as a property called \'wallet\', when initializing the psf-multisig-approval library.')
48
+ }
49
+ })
50
+
51
+ it('should have encapsulated dependencies', () => {
52
+ assert.property(uut, 'nfts')
53
+ })
54
+ })
55
+
56
+ describe('#getNftHolderInfo', () => {
57
+ it('should get info about NFTs associated with a group token', async () => {
58
+ // Mock dependencies and force desired code path
59
+ sandbox.stub(uut.nfts, 'getNftsFromGroup').resolves()
60
+ sandbox.stub(uut.nfts, 'getAddrsFromNfts').resolves()
61
+ sandbox.stub(uut.nfts, 'findKeys').resolves({ keys: [], keysNotFound: [] })
62
+
63
+ const result = await uut.getNftHolderInfo()
64
+
65
+ assert.property(result, 'keys')
66
+ assert.property(result, 'keysNotFound')
67
+ assert.isArray(result.keys)
68
+ assert.isArray(result.keysNotFound)
69
+ })
70
+
71
+ it('should catch, report, and throw errors', async () => {
72
+ try {
73
+ // Mock dependencies and force desired code path
74
+ sandbox.stub(uut.nfts, 'getNftsFromGroup').rejects(new Error('test error'))
75
+
76
+ await uut.getNftHolderInfo()
77
+
78
+ assert.fail('Unexpected code path')
79
+ } catch (err) {
80
+ assert.include(err.message, 'test error')
81
+ }
82
+ })
83
+ })
84
+
85
+ describe('#createMultisigAddress', () => {
86
+ it('should generate a P2SH multisig address', async () => {
87
+ const result = await uut.createMultisigAddress({ keys: mockData.pubkeys01 })
88
+ // console.log('result: ', result)
89
+
90
+ // Assert that expected properties exist
91
+ assert.property(result, 'address')
92
+ assert.property(result, 'scriptHex')
93
+ assert.property(result, 'publicKeys')
94
+ assert.property(result, 'requiredSigners')
95
+
96
+ // Assert that expected address is generated
97
+ assert.equal(result.address, 'bitcoincash:pqntzt6wcp38h8ud68wjnwh437uek76lhvhlwcm4fj')
98
+ })
99
+
100
+ it('should catch, report, and throw errors', async () => {
101
+ try {
102
+ await uut.createMultisigAddress()
103
+
104
+ assert.fail('unexpected result')
105
+ } catch (err) {
106
+ assert.include(err.message, 'keys must be an array containing public keys')
107
+ }
108
+ })
109
+ })
110
+
111
+ describe('#getApprovalTx', () => {
112
+ it('should return object with update txid', async () => {
113
+ // Mock dependencies and force desired code path.
114
+ sandbox.stub(uut.wallet, 'getTransactions').resolves(mockData.txHistory01)
115
+ sandbox.stub(uut.util, 'getTxData').resolves(mockData.approvalTxDetails01)
116
+
117
+ const address = 'bitcoincash:fake-addr'
118
+
119
+ const result = await uut.getApprovalTx({ address })
120
+ // console.log('result: ', result)
121
+
122
+ // Assert that the returned object has the expected properties.
123
+ assert.property(result, 'approvalTxid')
124
+ assert.property(result, 'updateTxid')
125
+ assert.property(result, 'approvalTxDetails')
126
+ assert.property(result, 'opReturn')
127
+
128
+ // Assert that TXIDs are returned.
129
+ assert.equal(result.updateTxid.length, 64)
130
+ assert.equal(result.approvalTxid.length, 64)
131
+ })
132
+
133
+ it('should handle SLP addresses', async () => {
134
+ // Mock dependencies and force desired code path.
135
+ sandbox.stub(uut.wallet, 'getTransactions').resolves(mockData.txHistory01)
136
+ sandbox.stub(uut.util, 'getTxData').resolves(mockData.approvalTxDetails01)
137
+
138
+ const address = 'simpleledger:qpq4uxk6vc2hn3rw8tevpm570xgs22e6rskpzpenqg'
139
+
140
+ const result = await uut.getApprovalTx({ address })
141
+ // console.log('result: ', result)
142
+
143
+ // Assert that the returned object has the expected properties.
144
+ assert.property(result, 'approvalTxid')
145
+ assert.property(result, 'updateTxid')
146
+ assert.property(result, 'approvalTxDetails')
147
+ assert.property(result, 'opReturn')
148
+
149
+ // Assert that TXIDs are returned.
150
+ assert.equal(result.updateTxid.length, 64)
151
+ assert.equal(result.approvalTxid.length, 64)
152
+ })
153
+
154
+ it('should skip a TXID in the filter list', async () => {
155
+ // Mock dependencies and force desired code path.
156
+ sandbox.stub(uut.wallet, 'getTransactions').resolves(mockData.txHistory02)
157
+ sandbox.stub(uut.util, 'getTxData').resolves(mockData.approvalTxDetails01)
158
+
159
+ const address = 'bitcoincash:fake-addr'
160
+
161
+ const result = await uut.getApprovalTx({
162
+ address,
163
+ filterTxids: ['095b299da0be5bb2367e62a5628cef603c7d6e709dd72f532632e9c0acf665d3']
164
+ })
165
+ // console.log('result: ', result)
166
+
167
+ // Assert that the returned object has the expected properties.
168
+ assert.property(result, 'approvalTxid')
169
+ assert.property(result, 'updateTxid')
170
+ assert.property(result, 'approvalTxDetails')
171
+ assert.property(result, 'opReturn')
172
+
173
+ // Assert that TXIDs are returned.
174
+ assert.equal(result.updateTxid.length, 64)
175
+ assert.equal(result.approvalTxid.length, 64)
176
+ })
177
+
178
+ it('should skip a TXID if it does contain APPROVAL in the OP_RETURN', async () => {
179
+ // Mock dependencies and force desired code path.
180
+ sandbox.stub(uut.wallet, 'getTransactions').resolves(mockData.txHistory02)
181
+ sandbox.stub(uut.util, 'getTxData')
182
+ .onCall(0).resolves(mockData.updateTxDetails01)
183
+ .onCall(1).resolves(mockData.approvalTxDetails01)
184
+
185
+ const address = 'bitcoincash:fake-addr'
186
+
187
+ const result = await uut.getApprovalTx({
188
+ address
189
+ })
190
+ // console.log('result: ', result)
191
+
192
+ // Assert that the returned object has the expected properties.
193
+ assert.property(result, 'approvalTxid')
194
+ assert.property(result, 'updateTxid')
195
+ assert.property(result, 'approvalTxDetails')
196
+ assert.property(result, 'opReturn')
197
+
198
+ // Assert that TXIDs are returned.
199
+ assert.equal(result.updateTxid.length, 64)
200
+ assert.equal(result.approvalTxid.length, 64)
201
+ })
202
+
203
+ it('should return null if approval TX can not be found', async () => {
204
+ // Mock dependencies and force desired code path.
205
+ sandbox.stub(uut.wallet, 'getTransactions').resolves(mockData.txHistory01)
206
+ sandbox.stub(uut.util, 'getTxData').resolves(mockData.updateTxDetails01)
207
+
208
+ const address = 'bitcoincash:fake-addr'
209
+
210
+ const result = await uut.getApprovalTx({ address })
211
+ // console.log('result: ', result)
212
+
213
+ assert.equal(result, null)
214
+ })
215
+
216
+ it('should throw an error if invalid address format is used', async () => {
217
+ try {
218
+ const address = 'fake-addr'
219
+
220
+ await uut.getApprovalTx({ address })
221
+
222
+ assert.fail('Unexpected code path')
223
+ } catch (err) {
224
+ assert.include(err.message, 'Input address must start with bitcoincash: or simpleledger:')
225
+ }
226
+ })
227
+ })
228
+
229
+ describe('#getUpdateTx', () => {
230
+ it('should get data from an update transaction', async () => {
231
+ // Mock dependencies and force desired code path
232
+ sandbox.stub(uut.util, 'getTxData').resolves(mockData.updateTxDetails01)
233
+
234
+ const txid = 'f8ea1fcd4481adfd62c6251c6a4f63f3d5ac3d5fdcc38b350d321d93254df65f'
235
+
236
+ const result = await uut.getUpdateTx({ txid })
237
+ // console.log('result: ', result)
238
+
239
+ // Assert returned object has expected properties
240
+ assert.property(result, 'cid')
241
+ assert.property(result, 'ts')
242
+ assert.property(result, 'txid')
243
+ assert.property(result, 'txDetails')
244
+ })
245
+
246
+ it('should throw an error if a txid is given as input', async () => {
247
+ try {
248
+ await uut.getUpdateTx()
249
+
250
+ assert.fail('Unexpected result')
251
+ } catch (err) {
252
+ assert.include(err.message, 'txid required')
253
+ }
254
+ })
255
+
256
+ it('should throw an error if OP_RETURN can not be decoded', async () => {
257
+ try {
258
+ // Mock dependencies and force desired code path
259
+ mockData.updateTxDetails01.vout[0].scriptPubKey.hex = '0123456789abcdef'
260
+ sandbox.stub(uut.util, 'getTxData').resolves(mockData.updateTxDetails01)
261
+
262
+ const txid = 'f8ea1fcd4481adfd62c6251c6a4f63f3d5ac3d5fdcc38b350d321d93254df65f'
263
+
264
+ await uut.getUpdateTx({ txid })
265
+
266
+ assert.fail('Unexpected result')
267
+ } catch (err) {
268
+ assert.include(err.message, 'Could not parse JSON inside')
269
+ }
270
+ })
271
+ })
272
+
273
+ describe('#getCidData', () => {
274
+ it('should resolve CID data from an IPFS gateway', async () => {
275
+ // Mock dependencies and force desired code path
276
+ sandbox.stub(uut.axios, 'get').resolves({ data: mockData.updateData01 })
277
+
278
+ const cid = 'bafybeib5d6s6t3tq4lhwp2ocvz7y2ws4czgkrmhlhv5y5aeyh6bqrmsxxi'
279
+
280
+ const result = await uut.getCidData({ cid })
281
+ // console.log('result: ', result)
282
+
283
+ // Assert that expected properties exist
284
+ assert.property(result, 'groupId')
285
+ assert.property(result, 'keys')
286
+ assert.property(result, 'walletObj')
287
+ assert.property(result, 'multisigAddr')
288
+ assert.property(result, 'p2wdbWritePrice')
289
+ })
290
+
291
+ it('should throw an error if CID is not specified', async () => {
292
+ try {
293
+ await uut.getCidData()
294
+
295
+ assert.fail('Unexpected code path')
296
+ } catch (err) {
297
+ assert.include(err.message, 'cid a required input')
298
+ }
299
+ })
300
+ })
301
+
302
+ describe('#validateApproval', () => {
303
+ it('should validate a valid approval transaction', async () => {
304
+ // Mock dependencies and force desired code path
305
+ sandbox.stub(uut, 'getNftHolderInfo').resolves(mockData.tokenHolderInfo01)
306
+
307
+ const inObj = {
308
+ approvalObj: mockData.approvalObj01,
309
+ updateObj: mockData.updateObj01,
310
+ updateData: mockData.updateData01
311
+ }
312
+
313
+ const result = await uut.validateApproval(inObj)
314
+
315
+ assert.equal(result, true)
316
+ })
317
+
318
+ it('should throw an error if approvalObj is not specified', async () => {
319
+ try {
320
+ await uut.validateApproval()
321
+
322
+ assert.fail('Unexpected code path')
323
+ } catch (err) {
324
+ assert.include(err.message, 'Output object of getApprovalTx() is expected as input to this function, as \'approvalObj\'')
325
+ }
326
+ })
327
+
328
+ it('should throw an error if updateObj is not specified', async () => {
329
+ try {
330
+ const inObj = {
331
+ approvalObj: mockData.approvalObj01
332
+ }
333
+
334
+ await uut.validateApproval(inObj)
335
+
336
+ assert.fail('Unexpected code path')
337
+ } catch (err) {
338
+ assert.include(err.message, 'Output object of getUpdateTx() is expected as input to this function, as \'updateObj\'')
339
+ }
340
+ })
341
+
342
+ it('should throw an error if updateData is not specified', async () => {
343
+ try {
344
+ const inObj = {
345
+ approvalObj: mockData.approvalObj01,
346
+ updateObj: mockData.updateObj01
347
+ }
348
+
349
+ await uut.validateApproval(inObj)
350
+
351
+ assert.fail('Unexpected code path')
352
+ } catch (err) {
353
+ assert.include(err.message, 'Update CID JSON data is expected as input to this function, as \'updateData\'')
354
+ }
355
+ })
356
+
357
+ it('should return false if addresses do not match', async () => {
358
+ // Mock dependencies and force desired code path
359
+ mockData.approvalObj01.approvalTxDetails.vin[0].address = 'bitcoincash:fake-addr'
360
+
361
+ const inObj = {
362
+ approvalObj: mockData.approvalObj01,
363
+ updateObj: mockData.updateObj01,
364
+ updateData: mockData.updateData01
365
+ }
366
+
367
+ const result = await uut.validateApproval(inObj)
368
+
369
+ assert.equal(result, false)
370
+ })
371
+ })
372
+ })
@@ -0,0 +1,290 @@
1
+ /*
2
+ Mock data for the main-index-unit.js unit test library.
3
+ */
4
+
5
+ const approvalTxDetails01 = {
6
+ txid: 'a63f9fbcc901316e6e89f5a8caaad6b2ab268278b29866c6c22088bd3ab93900',
7
+ hash: 'a63f9fbcc901316e6e89f5a8caaad6b2ab268278b29866c6c22088bd3ab93900',
8
+ version: 2,
9
+ size: 595,
10
+ locktime: 0,
11
+ vin: [
12
+ {
13
+ txid: 'f630f4db4b88c604e0670558782dfcfe7ad4b3d06c033dafa36f1505c3dbc58d',
14
+ vout: 0,
15
+ scriptSig: {
16
+ asm: '0 304402201474f95ab0e5fa3b5d6bd5f83d904c23a448f11c51a4b007b759663e76856e72022008b209df76b75e15422436f893b1b9f9f0671d65f41d0d419313f651e408c596[ALL|FORKID] 304402205ccff79c16a58da52ced457d6e898857df8fca650c7a4501406c95659c81f1e202201f79ab6615e75ae519ba8ee9d19718892dc07f3f307673149cafc5f487eb0ac0[ALL|FORKID] 3045022100dd9c0445509ada78622ae4551503c7bd84505bacfdb13994104e86e1c615a39f02205b895941fdd2a8082d27801904979992c4a6eaac3c85dd056c3c1b32865cff40[ALL|FORKID] 5321021ca211a04a1d489ae77e01c28c97b02e733893890fda00a359ca8956c2e0d25921024be54accec310c2636140336ae548d610ba9b7ce300b3f42494b4a6f2963731f21033c930d4cff4ba68a70f7a21443e20ad4176173380d21f8c3ce27f7ce947f3246210361fd21512b9072e8f6b984d9b04c57e5779867c2ad002999372268770fcb26742103b9bdc40c478ab0536be29c368b26c48a5e8d6867fc34b77c727ab690365aae9155ae',
17
+ hex: '0047304402201474f95ab0e5fa3b5d6bd5f83d904c23a448f11c51a4b007b759663e76856e72022008b209df76b75e15422436f893b1b9f9f0671d65f41d0d419313f651e408c5964147304402205ccff79c16a58da52ced457d6e898857df8fca650c7a4501406c95659c81f1e202201f79ab6615e75ae519ba8ee9d19718892dc07f3f307673149cafc5f487eb0ac041483045022100dd9c0445509ada78622ae4551503c7bd84505bacfdb13994104e86e1c615a39f02205b895941fdd2a8082d27801904979992c4a6eaac3c85dd056c3c1b32865cff40414cad5321021ca211a04a1d489ae77e01c28c97b02e733893890fda00a359ca8956c2e0d25921024be54accec310c2636140336ae548d610ba9b7ce300b3f42494b4a6f2963731f21033c930d4cff4ba68a70f7a21443e20ad4176173380d21f8c3ce27f7ce947f3246210361fd21512b9072e8f6b984d9b04c57e5779867c2ad002999372268770fcb26742103b9bdc40c478ab0536be29c368b26c48a5e8d6867fc34b77c727ab690365aae9155ae'
18
+ },
19
+ sequence: 4294967295,
20
+ address: 'bitcoincash:pqntzt6wcp38h8ud68wjnwh437uek76lhvhlwcm4fj',
21
+ value: 0.000756
22
+ }
23
+ ],
24
+ vout: [
25
+ {
26
+ value: 0,
27
+ n: 0,
28
+ scriptPubKey: {
29
+ asm: 'OP_RETURN 19516672076435521 66386561316663643434383161646664363263363235316336613466363366336435616333643566646363333862333530643332316439333235346466363566',
30
+ hex: '6a07415050524f56454066386561316663643434383161646664363263363235316336613466363366336435616333643566646363333862333530643332316439333235346466363566',
31
+ type: 'nulldata'
32
+ }
33
+ },
34
+ {
35
+ value: 0.00001,
36
+ n: 1,
37
+ scriptPubKey: {
38
+ asm: 'OP_DUP OP_HASH160 dd9d58d7672be6675262069534b173c113f59e85 OP_EQUALVERIFY OP_CHECKSIG',
39
+ hex: '76a914dd9d58d7672be6675262069534b173c113f59e8588ac',
40
+ reqSigs: 1,
41
+ type: 'pubkeyhash',
42
+ addresses: [
43
+ 'bitcoincash:qrwe6kxhvu47ve6jvgrf2d93w0q38av7s5xm9xfehr'
44
+ ]
45
+ }
46
+ },
47
+ {
48
+ value: 0.00072671,
49
+ n: 2,
50
+ scriptPubKey: {
51
+ asm: 'OP_HASH160 26b12f4ec0627b9f8dd1dd29baf58fb99b7b5fbb OP_EQUAL',
52
+ hex: 'a91426b12f4ec0627b9f8dd1dd29baf58fb99b7b5fbb87',
53
+ reqSigs: 1,
54
+ type: 'scripthash',
55
+ addresses: [
56
+ 'bitcoincash:pqntzt6wcp38h8ud68wjnwh437uek76lhvhlwcm4fj'
57
+ ]
58
+ }
59
+ }
60
+ ],
61
+ hex: '02000000018dc5dbc305156fa3af3d036cd0b3d47afefc2d78580567e004c6884bdbf430f600000000fd89010047304402201474f95ab0e5fa3b5d6bd5f83d904c23a448f11c51a4b007b759663e76856e72022008b209df76b75e15422436f893b1b9f9f0671d65f41d0d419313f651e408c5964147304402205ccff79c16a58da52ced457d6e898857df8fca650c7a4501406c95659c81f1e202201f79ab6615e75ae519ba8ee9d19718892dc07f3f307673149cafc5f487eb0ac041483045022100dd9c0445509ada78622ae4551503c7bd84505bacfdb13994104e86e1c615a39f02205b895941fdd2a8082d27801904979992c4a6eaac3c85dd056c3c1b32865cff40414cad5321021ca211a04a1d489ae77e01c28c97b02e733893890fda00a359ca8956c2e0d25921024be54accec310c2636140336ae548d610ba9b7ce300b3f42494b4a6f2963731f21033c930d4cff4ba68a70f7a21443e20ad4176173380d21f8c3ce27f7ce947f3246210361fd21512b9072e8f6b984d9b04c57e5779867c2ad002999372268770fcb26742103b9bdc40c478ab0536be29c368b26c48a5e8d6867fc34b77c727ab690365aae9155aeffffffff0300000000000000004a6a07415050524f56454066386561316663643434383161646664363263363235316336613466363366336435616333643566646363333862333530643332316439333235346466363566e8030000000000001976a914dd9d58d7672be6675262069534b173c113f59e8588acdf1b01000000000017a91426b12f4ec0627b9f8dd1dd29baf58fb99b7b5fbb8700000000',
62
+ blockhash: '000000000000000003e90bff17eeb147b0fb532abeddd5ba5a7ec23347e300ee',
63
+ confirmations: 6450,
64
+ time: 1677006961,
65
+ blocktime: 1677006961,
66
+ isValidSlp: false
67
+ }
68
+
69
+ const updateTxDetails01 = {
70
+ txid: 'f8ea1fcd4481adfd62c6251c6a4f63f3d5ac3d5fdcc38b350d321d93254df65f',
71
+ hash: 'f8ea1fcd4481adfd62c6251c6a4f63f3d5ac3d5fdcc38b350d321d93254df65f',
72
+ version: 2,
73
+ size: 361,
74
+ locktime: 0,
75
+ vin: [
76
+ {
77
+ txid: '2879a62158f0c3953750688e439d87737face939b5493b213f2e7d3bf505ddc4',
78
+ vout: 2,
79
+ scriptSig: {
80
+ asm: '3045022100919192436273a7b53994e151d6e2359934fcdb17f60f37954fab06f5012fccea02207c329deb48b0eaff25651360ac71d159b8b0bb49072aea3a6d4b657e61f24c30[ALL|FORKID] 02239ca86fcc2910aefb3bd06419c15bd542a7ce4e1c34c48ca9d398640cf94a3e',
81
+ hex: '483045022100919192436273a7b53994e151d6e2359934fcdb17f60f37954fab06f5012fccea02207c329deb48b0eaff25651360ac71d159b8b0bb49072aea3a6d4b657e61f24c30412102239ca86fcc2910aefb3bd06419c15bd542a7ce4e1c34c48ca9d398640cf94a3e'
82
+ },
83
+ sequence: 4294967295,
84
+ address: 'bitcoincash:qz4mn3ayguhyylz50zsg953yzs8ay3akrg3wle6qj6',
85
+ value: 0.00710985
86
+ }
87
+ ],
88
+ vout: [
89
+ {
90
+ value: 0,
91
+ n: 0,
92
+ scriptPubKey: {
93
+ asm: 'OP_RETURN 0 7b22636964223a226261667962656962356436733674337471346c687770326f63767a377932777334637a676b726d686c687635793561657968366271726d73787869222c227473223a313637363536303234373136387d',
94
+ hex: '6a004c587b22636964223a226261667962656962356436733674337471346c687770326f63767a377932777334637a676b726d686c687635793561657968366271726d73787869222c227473223a313637363536303234373136387d',
95
+ type: 'nulldata'
96
+ }
97
+ },
98
+ {
99
+ value: 0.00002,
100
+ n: 1,
101
+ scriptPubKey: {
102
+ asm: 'OP_DUP OP_HASH160 203b64bfbaa9e58333295b621159ddebc591ecb1 OP_EQUALVERIFY OP_CHECKSIG',
103
+ hex: '76a914203b64bfbaa9e58333295b621159ddebc591ecb188ac',
104
+ reqSigs: 1,
105
+ type: 'pubkeyhash',
106
+ addresses: [
107
+ 'bitcoincash:qqsrke9lh257tqen99dkyy2emh4uty0vky9y0z0lsr'
108
+ ]
109
+ }
110
+ },
111
+ {
112
+ value: 0.00708077,
113
+ n: 2,
114
+ scriptPubKey: {
115
+ asm: 'OP_DUP OP_HASH160 abb9c7a4472e427c5478a082d224140fd247b61a OP_EQUALVERIFY OP_CHECKSIG',
116
+ hex: '76a914abb9c7a4472e427c5478a082d224140fd247b61a88ac',
117
+ reqSigs: 1,
118
+ type: 'pubkeyhash',
119
+ addresses: [
120
+ 'bitcoincash:qz4mn3ayguhyylz50zsg953yzs8ay3akrg3wle6qj6'
121
+ ]
122
+ }
123
+ },
124
+ {
125
+ value: 0.00000546,
126
+ n: 3,
127
+ scriptPubKey: {
128
+ asm: 'OP_DUP OP_HASH160 dd9d58d7672be6675262069534b173c113f59e85 OP_EQUALVERIFY OP_CHECKSIG',
129
+ hex: '76a914dd9d58d7672be6675262069534b173c113f59e8588ac',
130
+ reqSigs: 1,
131
+ type: 'pubkeyhash',
132
+ addresses: [
133
+ 'bitcoincash:qrwe6kxhvu47ve6jvgrf2d93w0q38av7s5xm9xfehr'
134
+ ]
135
+ }
136
+ }
137
+ ],
138
+ hex: '0200000001c4dd05f53b7d2e3f213b49b539e9ac7f73879d438e68503795c3f05821a67928020000006b483045022100919192436273a7b53994e151d6e2359934fcdb17f60f37954fab06f5012fccea02207c329deb48b0eaff25651360ac71d159b8b0bb49072aea3a6d4b657e61f24c30412102239ca86fcc2910aefb3bd06419c15bd542a7ce4e1c34c48ca9d398640cf94a3effffffff0400000000000000005c6a004c587b22636964223a226261667962656962356436733674337471346c687770326f63767a377932777334637a676b726d686c687635793561657968366271726d73787869222c227473223a313637363536303234373136387dd0070000000000001976a914203b64bfbaa9e58333295b621159ddebc591ecb188acedcd0a00000000001976a914abb9c7a4472e427c5478a082d224140fd247b61a88ac22020000000000001976a914dd9d58d7672be6675262069534b173c113f59e8588ac00000000',
139
+ blockhash: '000000000000000001a1b31a8ec4a683a13fbe287209949e4dd54045860f776e',
140
+ confirmations: 7239,
141
+ time: 1676561115,
142
+ blocktime: 1676561115,
143
+ isValidSlp: false
144
+ }
145
+
146
+ const pubkeys01 = [
147
+ {
148
+ addr: 'bitcoincash:qz4zsa22glal5c4jqm748xge657gwuw2d5t9nvg64p',
149
+ pubKey: '021ca211a04a1d489ae77e01c28c97b02e733893890fda00a359ca8956c2e0d259',
150
+ nft: 'e86164aaa06efac1d6453951f67beafe042f0bceb9312845a95355b1e93aa846'
151
+ },
152
+ {
153
+ addr: 'bitcoincash:qpfvh07mdt7yq5czndaz5qq4g9q3m87qpspy7xaxgu',
154
+ pubKey: '0361fd21512b9072e8f6b984d9b04c57e5779867c2ad002999372268770fcb2674',
155
+ nft: 'da7ccbd5e24e468c9e7402489ca9148b5e76e588b73cc4aa4bbf1ca41d5808ab'
156
+ },
157
+ {
158
+ addr: 'bitcoincash:qpsxtzaa7rg677akcc2znpenpsy5jr2ygywmfd45p2',
159
+ pubKey: '03b9bdc40c478ab0536be29c368b26c48a5e8d6867fc34b77c727ab690365aae91',
160
+ nft: '0ec318bede8c2f229db840a24cb63d662ad91e8e6c840e46e6a8ff2d173049ce'
161
+ },
162
+ {
163
+ addr: 'bitcoincash:qqk3aczzggvxnfm7rwm0f9yz20yr00dmpv2f3tasdr',
164
+ pubKey: '033c930d4cff4ba68a70f7a21443e20ad4176173380d21f8c3ce27f7ce947f3246',
165
+ nft: '51624e772adafd7c6a9da38774e4f654282199bd5402e049ee087fc2bd900882'
166
+ },
167
+ {
168
+ addr: 'bitcoincash:qpszha37cjn6n83hpxn7zz5ndaa35vygtcgslxhpuc',
169
+ pubKey: '024be54accec310c2636140336ae548d610ba9b7ce300b3f42494b4a6f2963731f',
170
+ nft: 'e70cc72eeb15c82e96b1f8127d3b138b2fc8ea101fe9c62302ec641c05d4b97d'
171
+ }
172
+ ]
173
+
174
+ const txHistory01 = [{
175
+ height: 780917,
176
+ tx_hash: 'a63f9fbcc901316e6e89f5a8caaad6b2ab268278b29866c6c22088bd3ab93900'
177
+ }]
178
+
179
+ const txHistory02 = [
180
+ {
181
+ height: 781137,
182
+ tx_hash: '095b299da0be5bb2367e62a5628cef603c7d6e709dd72f532632e9c0acf665d3'
183
+ },
184
+ {
185
+ height: 780917,
186
+ tx_hash: 'a63f9fbcc901316e6e89f5a8caaad6b2ab268278b29866c6c22088bd3ab93900'
187
+ }
188
+ ]
189
+
190
+ const tokenHolderInfo01 = {
191
+ keys: [
192
+ {
193
+ addr: 'bitcoincash:qz4zsa22glal5c4jqm748xge657gwuw2d5t9nvg64p',
194
+ pubKey: '021ca211a04a1d489ae77e01c28c97b02e733893890fda00a359ca8956c2e0d259',
195
+ nft: 'e86164aaa06efac1d6453951f67beafe042f0bceb9312845a95355b1e93aa846'
196
+ },
197
+ {
198
+ addr: 'bitcoincash:qpfvh07mdt7yq5czndaz5qq4g9q3m87qpspy7xaxgu',
199
+ pubKey: '0361fd21512b9072e8f6b984d9b04c57e5779867c2ad002999372268770fcb2674',
200
+ nft: 'da7ccbd5e24e468c9e7402489ca9148b5e76e588b73cc4aa4bbf1ca41d5808ab'
201
+ },
202
+ {
203
+ addr: 'bitcoincash:qpsxtzaa7rg677akcc2znpenpsy5jr2ygywmfd45p2',
204
+ pubKey: '03b9bdc40c478ab0536be29c368b26c48a5e8d6867fc34b77c727ab690365aae91',
205
+ nft: '0ec318bede8c2f229db840a24cb63d662ad91e8e6c840e46e6a8ff2d173049ce'
206
+ },
207
+ {
208
+ addr: 'bitcoincash:qqk3aczzggvxnfm7rwm0f9yz20yr00dmpv2f3tasdr',
209
+ pubKey: '033c930d4cff4ba68a70f7a21443e20ad4176173380d21f8c3ce27f7ce947f3246',
210
+ nft: '51624e772adafd7c6a9da38774e4f654282199bd5402e049ee087fc2bd900882'
211
+ },
212
+ {
213
+ addr: 'bitcoincash:qpszha37cjn6n83hpxn7zz5ndaa35vygtcgslxhpuc',
214
+ pubKey: '024be54accec310c2636140336ae548d610ba9b7ce300b3f42494b4a6f2963731f',
215
+ nft: 'e70cc72eeb15c82e96b1f8127d3b138b2fc8ea101fe9c62302ec641c05d4b97d'
216
+ }
217
+ ],
218
+ keysNotFound: []
219
+ }
220
+
221
+ const updateData01 = {
222
+ groupId: '8e8d90ebdb1791d58eba7acd428ff3b1e21c47fb7aba2ba3b5b815aa0fe7d6d5',
223
+ keys: [
224
+ {
225
+ addr: 'bitcoincash:qz4zsa22glal5c4jqm748xge657gwuw2d5t9nvg64p',
226
+ pubKey: '021ca211a04a1d489ae77e01c28c97b02e733893890fda00a359ca8956c2e0d259',
227
+ nft: 'e86164aaa06efac1d6453951f67beafe042f0bceb9312845a95355b1e93aa846'
228
+ },
229
+ {
230
+ addr: 'bitcoincash:qpfvh07mdt7yq5czndaz5qq4g9q3m87qpspy7xaxgu',
231
+ pubKey: '0361fd21512b9072e8f6b984d9b04c57e5779867c2ad002999372268770fcb2674',
232
+ nft: 'da7ccbd5e24e468c9e7402489ca9148b5e76e588b73cc4aa4bbf1ca41d5808ab'
233
+ },
234
+ {
235
+ addr: 'bitcoincash:qpsxtzaa7rg677akcc2znpenpsy5jr2ygywmfd45p2',
236
+ pubKey: '03b9bdc40c478ab0536be29c368b26c48a5e8d6867fc34b77c727ab690365aae91',
237
+ nft: '0ec318bede8c2f229db840a24cb63d662ad91e8e6c840e46e6a8ff2d173049ce'
238
+ },
239
+ {
240
+ addr: 'bitcoincash:qqk3aczzggvxnfm7rwm0f9yz20yr00dmpv2f3tasdr',
241
+ pubKey: '033c930d4cff4ba68a70f7a21443e20ad4176173380d21f8c3ce27f7ce947f3246',
242
+ nft: '51624e772adafd7c6a9da38774e4f654282199bd5402e049ee087fc2bd900882'
243
+ },
244
+ {
245
+ addr: 'bitcoincash:qpszha37cjn6n83hpxn7zz5ndaa35vygtcgslxhpuc',
246
+ pubKey: '024be54accec310c2636140336ae548d610ba9b7ce300b3f42494b4a6f2963731f',
247
+ nft: 'e70cc72eeb15c82e96b1f8127d3b138b2fc8ea101fe9c62302ec641c05d4b97d'
248
+ }
249
+ ],
250
+ walletObj: {
251
+ address: 'bitcoincash:pqntzt6wcp38h8ud68wjnwh437uek76lhvhlwcm4fj',
252
+ scriptHex: 'a91426b12f4ec0627b9f8dd1dd29baf58fb99b7b5fbb87',
253
+ publicKeys: [
254
+ '021ca211a04a1d489ae77e01c28c97b02e733893890fda00a359ca8956c2e0d259',
255
+ '0361fd21512b9072e8f6b984d9b04c57e5779867c2ad002999372268770fcb2674',
256
+ '03b9bdc40c478ab0536be29c368b26c48a5e8d6867fc34b77c727ab690365aae91',
257
+ '033c930d4cff4ba68a70f7a21443e20ad4176173380d21f8c3ce27f7ce947f3246',
258
+ '024be54accec310c2636140336ae548d610ba9b7ce300b3f42494b4a6f2963731f'
259
+ ],
260
+ requiredSigners: 3
261
+ },
262
+ multisigAddr: 'bitcoincash:pqntzt6wcp38h8ud68wjnwh437uek76lhvhlwcm4fj',
263
+ p2wdbWritePrice: 0.08335233
264
+ }
265
+
266
+ const approvalObj01 = {
267
+ approvalTxid: 'a63f9fbcc901316e6e89f5a8caaad6b2ab268278b29866c6c22088bd3ab93900',
268
+ updateTxid: 'f8ea1fcd4481adfd62c6251c6a4f63f3d5ac3d5fdcc38b350d321d93254df65f',
269
+ approvalTxDetails: approvalTxDetails01,
270
+ opReturn: 'j\x07APPROVE@f8ea1fcd4481adfd62c6251c6a4f63f3d5ac3d5fdcc38b350d321d93254df65f'
271
+ }
272
+
273
+ const updateObj01 = {
274
+ cid: 'bafybeib5d6s6t3tq4lhwp2ocvz7y2ws4czgkrmhlhv5y5aeyh6bqrmsxxi',
275
+ ts: 1676560247168,
276
+ txid: 'f8ea1fcd4481adfd62c6251c6a4f63f3d5ac3d5fdcc38b350d321d93254df65f',
277
+ txDetails: updateTxDetails01
278
+ }
279
+
280
+ module.exports = {
281
+ pubkeys01,
282
+ txHistory01,
283
+ txHistory02,
284
+ approvalTxDetails01,
285
+ updateTxDetails01,
286
+ tokenHolderInfo01,
287
+ updateData01,
288
+ approvalObj01,
289
+ updateObj01
290
+ }
@@ -0,0 +1,32 @@
1
+ /*
2
+ A mocking library for util.js unit tests.
3
+ A mocking library contains data to use in place of the data that would come
4
+ from an external dependency.
5
+ */
6
+
7
+ 'use strict'
8
+
9
+ const mockBalance = {
10
+ success: true,
11
+ balance: {
12
+ confirmed: 1000,
13
+ unconfirmed: 0
14
+ }
15
+ }
16
+
17
+ const mockUtxos = {
18
+ success: true,
19
+ utxos: [
20
+ {
21
+ height: 601861,
22
+ tx_hash: '6181c669614fa18039a19b23eb06806bfece1f7514ab457c3bb82a40fe171a6d',
23
+ tx_pos: 0,
24
+ value: 1000
25
+ }
26
+ ]
27
+ }
28
+
29
+ module.exports = {
30
+ mockBalance,
31
+ mockUtxos
32
+ }