@@ -237,41 +237,44 @@ describe('BitGo Prototype Methods', function () {
237237 'xpub661MyMwAqRbcEusRjkJ64BXgR8ddYsXbuDJfbRc3eZcZVEa2ygswDiFZQpHFsA5N211YDvi2N898h4KrcXcfsR8PLhjJaPUwCUqg1ptBBHN' ;
238238 const passwords = [ 'mickey' , 'mouse' , 'donald' , 'duck' ] ;
239239
240- it ( 'should fail to split secret with wrong m' , ( ) => {
241- ( ( ) =>
242- bitgo . splitSecret ( {
240+ it ( 'should fail to split secret with wrong m' , async ( ) => {
241+ await bitgo
242+ . splitSecret ( {
243243 seed,
244244 passwords : [ 'abc' ] ,
245245 m : 0 ,
246- } ) ) . should . throw ( 'm must be a positive integer greater than or equal to 2' ) ;
246+ } )
247+ . should . be . rejectedWith ( 'm must be a positive integer greater than or equal to 2' ) ;
247248 } ) ;
248249
249- it ( 'should fail to split secret with bad password count' , ( ) => {
250- ( ( ) =>
251- bitgo . splitSecret ( {
250+ it ( 'should fail to split secret with bad password count' , async ( ) => {
251+ await bitgo
252+ . splitSecret ( {
252253 seed,
253254 passwords : [ 'abc' ] ,
254255 m : 2 ,
255- } ) ) . should . throw ( 'passwords array length cannot be less than m' ) ;
256+ } )
257+ . should . be . rejectedWith ( 'passwords array length cannot be less than m' ) ;
256258 } ) ;
257259
258- it ( 'should split and fail to reconstitute secret with bad passwords' , ( ) => {
259- const splitSecret = bitgo . splitSecret ( { seed, passwords : passwords , m : 3 } ) ;
260+ it ( 'should split and fail to reconstitute secret with bad passwords' , async ( ) => {
261+ const splitSecret = await bitgo . splitSecret ( { seed, passwords : passwords , m : 3 } ) ;
260262 const shards = _ . at ( splitSecret . seedShares , [ 0 , 2 ] ) ;
261263 const subsetPasswords = _ . at ( passwords , [ 0 , 3 ] ) ;
262- ( ( ) =>
263- bitgo . reconstituteSecret ( {
264+ await bitgo
265+ . reconstituteSecret ( {
264266 shards,
265267 passwords : subsetPasswords ,
266268 xpub,
267- } as any ) ) . should . throw ( / c c m : t a g d o e s n ' t m a t c h / ) ;
269+ } as any )
270+ . should . be . rejectedWith ( / c c m : t a g d o e s n ' t m a t c h / ) ;
268271 } ) ;
269272
270- it ( 'should split and reconstitute secret' , ( ) => {
271- const splitSecret = bitgo . splitSecret ( { seed, passwords : passwords , m : 2 } ) ;
273+ it ( 'should split and reconstitute secret' , async ( ) => {
274+ const splitSecret = await bitgo . splitSecret ( { seed, passwords : passwords , m : 2 } ) ;
272275 const shards = _ . at ( splitSecret . seedShares , [ 0 , 2 ] ) ;
273276 const subsetPasswords = _ . at ( passwords , [ 0 , 2 ] ) ;
274- const reconstitutedSeed = bitgo . reconstituteSecret ( { shards, passwords : subsetPasswords } ) ;
277+ const reconstitutedSeed = await bitgo . reconstituteSecret ( { shards, passwords : subsetPasswords } ) ;
275278 reconstitutedSeed . seed . should . equal ( seed ) ;
276279 reconstitutedSeed . xpub . should . equal (
277280 'xpub661MyMwAqRbcEusRjkJ64BXgR8ddYsXbuDJfbRc3eZcZVEa2ygswDiFZQpHFsA5N211YDvi2N898h4KrcXcfsR8PLhjJaPUwCUqg1ptBBHN'
@@ -281,22 +284,22 @@ describe('BitGo Prototype Methods', function () {
281284 ) ;
282285 } ) ;
283286
284- it ( 'should split and incorrectly verify secret' , ( ) => {
285- const splitSecret = bitgo . splitSecret ( { seed, passwords : passwords , m : 3 } ) ;
286- const isValid = bitgo . verifyShards ( { shards : splitSecret . seedShares , passwords, m : 2 } as any ) ;
287+ it ( 'should split and incorrectly verify secret' , async ( ) => {
288+ const splitSecret = await bitgo . splitSecret ( { seed, passwords : passwords , m : 3 } ) ;
289+ const isValid = await bitgo . verifyShards ( { shards : splitSecret . seedShares , passwords, m : 2 } as any ) ;
287290 isValid . should . equal ( false ) ;
288291 } ) ;
289292
290- it ( 'should split and verify secret' , ( ) => {
291- const splitSecret = bitgo . splitSecret ( { seed, passwords : passwords , m : 2 } ) ;
292- const isValid = bitgo . verifyShards ( { shards : splitSecret . seedShares , passwords, m : 2 , xpub } ) ;
293+ it ( 'should split and verify secret' , async ( ) => {
294+ const splitSecret = await bitgo . splitSecret ( { seed, passwords : passwords , m : 2 } ) ;
295+ const isValid = await bitgo . verifyShards ( { shards : splitSecret . seedShares , passwords, m : 2 , xpub } ) ;
293296 isValid . should . equal ( true ) ;
294297 } ) ;
295298
296- it ( 'should split and verify secret with many parts' , ( ) => {
299+ it ( 'should split and verify secret with many parts' , async ( ) => {
297300 const allPws = [ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' ] ;
298- const splitSecret = bitgo . splitSecret ( { seed, passwords : allPws , m : 3 } ) ;
299- const isValid = bitgo . verifyShards ( { shards : splitSecret . seedShares , passwords : allPws , m : 3 , xpub } ) ;
301+ const splitSecret = await bitgo . splitSecret ( { seed, passwords : allPws , m : 3 } ) ;
302+ const isValid = await bitgo . verifyShards ( { shards : splitSecret . seedShares , passwords : allPws , m : 3 , xpub } ) ;
300303 isValid . should . equal ( true ) ;
301304 } ) ;
302305 } ) ;
@@ -436,15 +439,15 @@ describe('BitGo Prototype Methods', function () {
436439 requestHeaders . hmac . should . equal ( '6de77d5a5446a3e5649456c11480706a71071b15639c3c787af65bdb02ecf1ec' ) ;
437440 } ) ;
438441
439- it ( 'should correctly handle authentication response' , ( ) => {
442+ it ( 'should correctly handle authentication response' , async ( ) => {
440443 const responseJson = {
441444 encryptedToken :
442445 '{"iv":"EqxVaGTLY4naAYkuBaTz0w==","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"4S4dBYcgL4s=","ct":"FgBRJljb8iSYxnAjMi4Qotr7sTKbSmWnlfHZShMSi8YeeE3kiS8bpHNUwAPhY8tgouh3UsEwrJnY+54MvqFD7yd19pG1V4CVssr8"}' ,
443446 derivationPath : 'm/999999/104490948/173846667' ,
444447 encryptedECDHXprv :
445448 '{"iv":"QKHEF2GNcwOJwy6+pwANRA==","v":1,"iter":10000,"ks":256,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"W2sVFvXDlOw=","ct":"8BTCqS25X37kLzmzQdGenhXH6znn9qEmkszAeS8kLnRdqKSiUiC7bTAVgg/Np5yrV7F7Jyiq+MTpVT76EoUT+PMJzArv0gUQKC2JPB3JuVKeAAVWBQmhWfkEwRfyv4hq4WMxwZtocwBqThvd2pJm9HE51GX4/Wo="}' ,
446449 } ;
447- const parsedAuthenticationData = bitgo . handleTokenIssuance ( responseJson , 'test@bitgo.com' ) ;
450+ const parsedAuthenticationData = await bitgo . handleTokenIssuance ( responseJson , 'test@bitgo.com' ) ;
448451 parsedAuthenticationData . token . should . equal ( token ) ;
449452 parsedAuthenticationData . ecdhXprv . should . equal (
450453 'xprv9s21ZrQH143K3si1bKGp7KqgCQv39ttQ7aUwWzVdytgHd8HtDCHyEp14mxfhiT3qHTq4BaSrA7uUkG6AJTfPJBsRu63drvBqYuMZyTxepH7'
0 commit comments