1+ import assert from 'assert' ;
2+
13import * as utxolib from '@bitgo/utxo-lib' ;
2- import 'should' ;
34import * as sinon from 'sinon' ;
45import { Wallet } from '@bitgo/sdk-core' ;
56
@@ -85,69 +86,71 @@ describe('Verify Transaction', function () {
8586 sinon . stub ( coin , 'parseTransaction' ) . resolves ( stubData . parseTransactionData . badKey as any ) ;
8687 const verifyWallet = sinon . createStubInstance ( Wallet , { } ) ;
8788
88- await coin
89- . verifyTransaction ( {
89+ await assert . rejects (
90+ coin . verifyTransaction ( {
9091 txParams : {
9192 walletPassphrase : passphrase ,
9293 } ,
9394 txPrebuild : { } ,
9495 wallet : verifyWallet as any ,
9596 verification : { } ,
96- } )
97- . should . be . rejectedWith ( / t r a n s a c t i o n r e q u i r e s v e r i f i c a t i o n o f u s e r p u b l i c k e y , b u t i t w a s u n a b l e t o b e v e r i f i e d / ) ;
97+ } ) ,
98+ / t r a n s a c t i o n r e q u i r e s v e r i f i c a t i o n o f u s e r p u b l i c k e y , b u t i t w a s u n a b l e t o b e v e r i f i e d /
99+ ) ;
98100
99101 ( coin . parseTransaction as any ) . restore ( ) ;
100102 } ) ;
101103
102104 it ( 'should fail if the custom change verification data is required but missing' , async ( ) => {
103105 sinon . stub ( coin , 'parseTransaction' ) . resolves ( stubData . parseTransactionData . noCustomChange as any ) ;
104106
105- await coin
106- . verifyTransaction ( {
107+ await assert . rejects (
108+ coin . verifyTransaction ( {
107109 txParams : {
108110 walletPassphrase : passphrase ,
109111 } ,
110112 txPrebuild : { } ,
111113 wallet : unsignedSendingWallet as any ,
112114 verification : { } ,
113- } )
114- . should . be . rejectedWith ( / p a r s e d t r a n s a c t i o n i s m i s s i n g r e q u i r e d c u s t o m c h a n g e v e r i f i c a t i o n d a t a / ) ;
115+ } ) ,
116+ / p a r s e d t r a n s a c t i o n i s m i s s i n g r e q u i r e d c u s t o m c h a n g e v e r i f i c a t i o n d a t a /
117+ ) ;
115118
116119 ( coin . parseTransaction as any ) . restore ( ) ;
117120 } ) ;
118121
119122 it ( 'should fail if the custom change keys or key signatures are missing' , async ( ) => {
120123 sinon . stub ( coin , 'parseTransaction' ) . resolves ( stubData . parseTransactionData . emptyCustomChange as any ) ;
121124
122- await coin
123- . verifyTransaction ( {
125+ await assert . rejects (
126+ coin . verifyTransaction ( {
124127 txParams : {
125128 walletPassphrase : passphrase ,
126129 } ,
127130 txPrebuild : { } ,
128131 wallet : unsignedSendingWallet as any ,
129132 verification : { } ,
130- } )
131- . should . be . rejectedWith ( / c u s t o m C h a n g e p r o p e r t y i s m i s s i n g k e y s o r s i g n a t u r e s / ) ;
133+ } ) ,
134+ / c u s t o m C h a n g e p r o p e r t y i s m i s s i n g k e y s o r s i g n a t u r e s /
135+ ) ;
132136
133137 ( coin . parseTransaction as any ) . restore ( ) ;
134138 } ) ;
135139
136140 it ( 'should fail if the custom change key signatures cannot be verified' , async ( ) => {
137141 sinon . stub ( coin , 'parseTransaction' ) . resolves ( ( await stubData . parseTransactionData . badSigs ( ) ) as any ) ;
138142
139- await coin
140- . verifyTransaction ( {
143+ await assert . rejects (
144+ coin . verifyTransaction ( {
141145 txParams : {
142146 walletPassphrase : passphrase ,
143147 } ,
144148 txPrebuild : { } ,
145149 wallet : unsignedSendingWallet as any ,
146150 verification : { } ,
147- } )
148- . should . be . rejectedWith (
149- / t r a n s a c t i o n r e q u i r e s v e r i f i c a t i o n o f c u s t o m c h a n g e k e y s i g n a t u r e s , b u t t h e y w e r e u n a b l e t o b e v e r i f i e d /
150- ) ;
151+ } ) ,
152+ / t r a n s a c t i o n r e q u i r e s v e r i f i c a t i o n o f c u s t o m c h a n g e k e y s i g n a t u r e s , b u t t h e y w e r e u n a b l e t o b e v e r i f i e d /
153+ ) ;
151154
152155 ( coin . parseTransaction as any ) . restore ( ) ;
153156 } ) ;
@@ -157,16 +160,17 @@ describe('Verify Transaction', function () {
157160
158161 // if verify transaction gets rejected with the outputs missing error message,
159162 // then we know that the verification of the custom change key signatures was successful
160- await coin
161- . verifyTransaction ( {
163+ await assert . rejects (
164+ coin . verifyTransaction ( {
162165 txParams : {
163166 walletPassphrase : passphrase ,
164167 } ,
165168 txPrebuild : { } ,
166169 wallet : unsignedSendingWallet as any ,
167170 verification : { } ,
168- } )
169- . should . be . rejectedWith ( / e x p e c t e d o u t p u t s m i s s i n g i n t r a n s a c t i o n p r e b u i l d / ) ;
171+ } ) ,
172+ / e x p e c t e d o u t p u t s m i s s i n g i n t r a n s a c t i o n p r e b u i l d /
173+ ) ;
170174
171175 ( coin . parseTransaction as any ) . restore ( ) ;
172176 } ) ;
@@ -185,15 +189,16 @@ describe('Verify Transaction', function () {
185189 needsCustomChangeKeySignatureVerification : false ,
186190 } ) ;
187191
188- await coin
189- . verifyTransaction ( {
192+ await assert . rejects (
193+ coin . verifyTransaction ( {
190194 txParams : {
191195 walletPassphrase : passphrase ,
192196 } ,
193197 txPrebuild : { } ,
194198 wallet : unsignedSendingWallet as any ,
195- } )
196- . should . be . rejectedWith ( 'prebuild attempts to spend to unintended external recipients' ) ;
199+ } ) ,
200+ / p r e b u i l d a t t e m p t s t o s p e n d t o u n i n t e n d e d e x t e r n a l r e c i p i e n t s /
201+ ) ;
197202
198203 coinMock . restore ( ) ;
199204 } ) ;
@@ -216,17 +221,17 @@ describe('Verify Transaction', function () {
216221 . stub ( coin , 'createTransactionFromHex' )
217222 . returns ( { ins : [ ] } as unknown as utxolib . bitgo . UtxoTransaction ) ;
218223
219- await coin
220- . verifyTransaction ( {
221- txParams : {
222- walletPassphrase : passphrase ,
223- } ,
224- txPrebuild : {
225- txHex : '00' ,
226- } ,
227- wallet : unsignedSendingWallet as any ,
228- } )
229- . should . eventually . be . true ( ) ;
224+ const result = await coin . verifyTransaction ( {
225+ txParams : {
226+ walletPassphrase : passphrase ,
227+ } ,
228+ txPrebuild : {
229+ txHex : '00' ,
230+ } ,
231+ wallet : unsignedSendingWallet as any ,
232+ } ) ;
233+
234+ assert . strictEqual ( result , true ) ;
230235
231236 coinMock . restore ( ) ;
232237 bitcoinMock . restore ( ) ;
@@ -246,8 +251,8 @@ describe('Verify Transaction', function () {
246251 needsCustomChangeKeySignatureVerification : false ,
247252 } ) ;
248253
249- await coin
250- . verifyTransaction ( {
254+ await assert . rejects (
255+ coin . verifyTransaction ( {
251256 txParams : {
252257 walletPassphrase : passphrase ,
253258 } ,
@@ -258,8 +263,9 @@ describe('Verify Transaction', function () {
258263 verification : {
259264 allowPaygoOutput : false ,
260265 } ,
261- } )
262- . should . be . rejectedWith ( 'prebuild attempts to spend to unintended external recipients' ) ;
266+ } ) ,
267+ / p r e b u i l d a t t e m p t s t o s p e n d t o u n i n t e n d e d e x t e r n a l r e c i p i e n t s /
268+ ) ;
263269
264270 coinMock . restore ( ) ;
265271 } ) ;
@@ -282,18 +288,18 @@ describe('Verify Transaction', function () {
282288 . stub ( coin , 'createTransactionFromHex' )
283289 . returns ( { ins : [ ] } as unknown as utxolib . bitgo . UtxoTransaction ) ;
284290
285- await coin
286- . verifyTransaction ( {
287- txParams : {
288- walletPassphrase : passphrase ,
289- } ,
290- txPrebuild : {
291- txHex : '00' ,
292- } ,
293- wallet : unsignedSendingWallet as any ,
294- verification : { } ,
295- } )
296- . should . eventually . be . true ( ) ;
291+ const result = await coin . verifyTransaction ( {
292+ txParams : {
293+ walletPassphrase : passphrase ,
294+ } ,
295+ txPrebuild : {
296+ txHex : '00' ,
297+ } ,
298+ wallet : unsignedSendingWallet as any ,
299+ verification : { } ,
300+ } ) ;
301+
302+ assert . strictEqual ( result , true ) ;
297303
298304 coinMock . restore ( ) ;
299305 bitcoinMock . restore ( ) ;
@@ -330,18 +336,18 @@ describe('Verify Transaction', function () {
330336 . stub ( bigintCoin , 'createTransactionFromHex' )
331337 . returns ( { ins : [ ] } as unknown as utxolib . bitgo . UtxoTransaction ) ;
332338
333- await bigintCoin
334- . verifyTransaction ( {
335- txParams : {
336- walletPassphrase : passphrase ,
337- } ,
338- txPrebuild : {
339- txHex : '00' ,
340- } ,
341- wallet : unsignedSendingWallet as any ,
342- verification : { } ,
343- } )
344- . should . eventually . be . true ( ) ;
339+ const result = await bigintCoin . verifyTransaction ( {
340+ txParams : {
341+ walletPassphrase : passphrase ,
342+ } ,
343+ txPrebuild : {
344+ txHex : '00' ,
345+ } ,
346+ wallet : unsignedSendingWallet as any ,
347+ verification : { } ,
348+ } ) ;
349+
350+ assert . strictEqual ( result , true ) ;
345351
346352 coinMock . restore ( ) ;
347353 bitcoinMock . restore ( ) ;
0 commit comments