psf-multisig-approval 1.0.4 → 2.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.
- package/README.md +142 -5
- package/index.js +284 -4
- package/lib/util.js +30 -30
- package/package.json +3 -2
- package/test/integration/main-index-integration.js +89 -3
- package/test/unit/main-index-unit.js +296 -8
- package/test/unit/mocks/main-index-mocks.js +290 -0
- package/test/unit/util-unit.js +91 -0
|
@@ -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,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Unit tests for the util.js utility library.
|
|
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
|
+
// Local libraries
|
|
12
|
+
// const mockDataLib = require('./mocks/util-mocks')
|
|
13
|
+
|
|
14
|
+
// Unit under test
|
|
15
|
+
const UtilLib = require('../../lib/util')
|
|
16
|
+
|
|
17
|
+
describe('#Util', () => {
|
|
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 UtilLib({ 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 UtilLib()
|
|
44
|
+
console.log('uut: ', uut)
|
|
45
|
+
|
|
46
|
+
assert.fail('Unexpected result')
|
|
47
|
+
} catch (err) {
|
|
48
|
+
assert.include(err.message, 'Instance of minimal-slp-wallet must be passed in as a property called \'wallet\', when initializing the util library.')
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
describe('#getTxData', () => {
|
|
54
|
+
it('should get TX data from the full node', async () => {
|
|
55
|
+
// Mock dependencies and force desired code path
|
|
56
|
+
sandbox.stub(uut.wallet, 'getTxData').resolves([{ txid: 'fake-txid' }])
|
|
57
|
+
|
|
58
|
+
const txid = 'fake-txid'
|
|
59
|
+
|
|
60
|
+
const result = await uut.getTxData(txid)
|
|
61
|
+
// console.log('result: ', result)
|
|
62
|
+
|
|
63
|
+
assert.equal(result.txid, 'fake-txid')
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('should get TX data from the cache', async () => {
|
|
67
|
+
// Mock dependencies and force desired code path
|
|
68
|
+
sandbox.stub(uut.wallet, 'getTxData').rejects(new Error('test error'))
|
|
69
|
+
uut.txCache['fake-txid'] = { txid: 'fake-txid' }
|
|
70
|
+
|
|
71
|
+
const txid = 'fake-txid'
|
|
72
|
+
|
|
73
|
+
const result = await uut.getTxData(txid)
|
|
74
|
+
// console.log('result: ', result)
|
|
75
|
+
|
|
76
|
+
// Assert expected result
|
|
77
|
+
assert.equal(result.txid, 'fake-txid')
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('should catch, report, and throw an error', async () => {
|
|
81
|
+
try {
|
|
82
|
+
await uut.getTxData()
|
|
83
|
+
|
|
84
|
+
assert.fail('Unexpected result')
|
|
85
|
+
} catch (err) {
|
|
86
|
+
// console.log('err.message: ', err.message)
|
|
87
|
+
assert.include(err.message, 'txid (transactoin ID) required')
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
})
|