@@ -129,23 +129,23 @@ describe("Libsodium", () => {
129129 // 8 bytes
130130 await Argon2id . execute ( password , fromHex ( "aabbccddeeff0011" ) , options )
131131 . then ( ( ) => {
132- fail ( "Argon2id with invalid salt length must not resolve" ) ;
132+ throw new Error ( "Argon2id with invalid salt length must not resolve" ) ;
133133 } )
134134 . catch ( ( e ) => {
135135 expect ( e ) . toMatch ( / i n v a l i d s a l t l e n g t h / ) ;
136136 } ) ;
137137 // 15 bytes
138138 await Argon2id . execute ( password , fromHex ( "aabbccddeeff001122334455667788" ) , options )
139139 . then ( ( ) => {
140- fail ( "Argon2id with invalid salt length must not resolve" ) ;
140+ throw new Error ( "Argon2id with invalid salt length must not resolve" ) ;
141141 } )
142142 . catch ( ( e ) => {
143143 expect ( e ) . toMatch ( / i n v a l i d s a l t l e n g t h / ) ;
144144 } ) ;
145145 // 17 bytes
146146 await Argon2id . execute ( password , fromHex ( "aabbccddeeff00112233445566778899aa" ) , options )
147147 . then ( ( ) => {
148- fail ( "Argon2id with invalid salt length must not resolve" ) ;
148+ throw new Error ( "Argon2id with invalid salt length must not resolve" ) ;
149149 } )
150150 . catch ( ( e ) => {
151151 expect ( e ) . toMatch ( / i n v a l i d s a l t l e n g t h / ) ;
@@ -157,7 +157,7 @@ describe("Libsodium", () => {
157157 options ,
158158 )
159159 . then ( ( ) => {
160- fail ( "Argon2id with invalid salt length must not resolve" ) ;
160+ throw new Error ( "Argon2id with invalid salt length must not resolve" ) ;
161161 } )
162162 . catch ( ( e ) => {
163163 expect ( e ) . toMatch ( / i n v a l i d s a l t l e n g t h / ) ;
@@ -235,7 +235,7 @@ describe("Libsodium", () => {
235235 const seed = fromHex ( "43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0" ) ;
236236 await Ed25519 . makeKeypair ( seed )
237237 . then ( ( ) => {
238- fail ( "promise must not resolve" ) ;
238+ throw new Error ( "promise must not resolve" ) ;
239239 } )
240240 . catch ( ( error ) => {
241241 expect ( error . message ) . toContain ( "key of length 32 expected" ) ;
@@ -247,7 +247,7 @@ describe("Libsodium", () => {
247247 const seed = fromHex ( "43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9aa" ) ;
248248 await Ed25519 . makeKeypair ( seed )
249249 . then ( ( ) => {
250- fail ( "promise must not resolve" ) ;
250+ throw new Error ( "promise must not resolve" ) ;
251251 } )
252252 . catch ( ( error ) => {
253253 expect ( error . message ) . toContain ( "key of length 32 expected" ) ;
@@ -423,7 +423,7 @@ describe("Libsodium", () => {
423423 const key = fromHex ( "" ) ;
424424 await Xchacha20poly1305Ietf . encrypt ( message , key , nonce )
425425 . then ( ( ) => {
426- fail ( "encryption must not succeed" ) ;
426+ throw new Error ( "encryption must not succeed" ) ;
427427 } )
428428 . catch ( ( error ) => {
429429 expect ( error ) . toMatch ( / k e y , g o t l e n g t h = 0 / ) ;
@@ -434,7 +434,7 @@ describe("Libsodium", () => {
434434 const key = fromHex ( "1324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916" ) ;
435435 await Xchacha20poly1305Ietf . encrypt ( message , key , nonce )
436436 . then ( ( ) => {
437- fail ( "encryption must not succeed" ) ;
437+ throw new Error ( "encryption must not succeed" ) ;
438438 } )
439439 . catch ( ( error ) => {
440440 expect ( error ) . toMatch ( / k e y , g o t l e n g t h = 3 1 / ) ;
@@ -445,7 +445,7 @@ describe("Libsodium", () => {
445445 const key = fromHex ( "1324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916d8aa" ) ;
446446 await Xchacha20poly1305Ietf . encrypt ( message , key , nonce )
447447 . then ( ( ) => {
448- fail ( "encryption must not succeed" ) ;
448+ throw new Error ( "encryption must not succeed" ) ;
449449 } )
450450 . catch ( ( error ) => {
451451 expect ( error ) . toMatch ( / k e y , g o t l e n g t h = 3 3 / ) ;
@@ -458,7 +458,7 @@ describe("Libsodium", () => {
458458 ) ;
459459 await Xchacha20poly1305Ietf . encrypt ( message , key , nonce )
460460 . then ( ( ) => {
461- fail ( "encryption must not succeed" ) ;
461+ throw new Error ( "encryption must not succeed" ) ;
462462 } )
463463 . catch ( ( error ) => {
464464 expect ( error ) . toMatch ( / k e y , g o t l e n g t h = 6 4 / ) ;
@@ -484,7 +484,7 @@ describe("Libsodium", () => {
484484 const corruptedCiphertext = ciphertext . map ( ( x , i ) => ( i === 0 ? x ^ 0x01 : x ) ) ;
485485 await Xchacha20poly1305Ietf . decrypt ( corruptedCiphertext , key , nonce ) . then (
486486 ( ) => {
487- fail ( "promise must not resolve" ) ;
487+ throw new Error ( "promise must not resolve" ) ;
488488 } ,
489489 ( error ) => {
490490 expect ( error . message ) . toMatch ( / i n v a l i d t a g / i) ;
@@ -496,7 +496,7 @@ describe("Libsodium", () => {
496496 const corruptedKey = key . map ( ( x , i ) => ( i === 0 ? x ^ 0x01 : x ) ) ;
497497 await Xchacha20poly1305Ietf . decrypt ( ciphertext , corruptedKey , nonce ) . then (
498498 ( ) => {
499- fail ( "promise must not resolve" ) ;
499+ throw new Error ( "promise must not resolve" ) ;
500500 } ,
501501 ( error ) => {
502502 expect ( error . message ) . toMatch ( / i n v a l i d t a g / i) ;
@@ -508,7 +508,7 @@ describe("Libsodium", () => {
508508 const corruptedNonce = nonce . map ( ( x , i ) => ( i === 0 ? x ^ 0x01 : x ) ) ;
509509 await Xchacha20poly1305Ietf . decrypt ( ciphertext , key , corruptedNonce ) . then (
510510 ( ) => {
511- fail ( "promise must not resolve" ) ;
511+ throw new Error ( "promise must not resolve" ) ;
512512 } ,
513513 ( error ) => {
514514 expect ( error . message ) . toMatch ( / i n v a l i d t a g / i) ;
0 commit comments