@@ -18,17 +18,31 @@ assert.strictEqual(
1818 'should consider unequal strings to be unequal'
1919) ;
2020
21- assert . throws ( function ( ) {
22- crypto . timingSafeEqual ( Buffer . from ( [ 1 , 2 , 3 ] ) , Buffer . from ( [ 1 , 2 ] ) ) ;
23- } , / ^ T y p e E r r o r : I n p u t b u f f e r s m u s t h a v e t h e s a m e l e n g t h $ / ,
24- 'should throw when given buffers with different lengths' ) ;
21+ common . expectsError (
22+ ( ) => crypto . timingSafeEqual ( Buffer . from ( [ 1 , 2 , 3 ] ) , Buffer . from ( [ 1 , 2 ] ) ) ,
23+ {
24+ code : 'ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH' ,
25+ type : RangeError ,
26+ message : 'Input buffers must have the same length'
27+ }
28+ ) ;
2529
26- assert . throws ( function ( ) {
27- crypto . timingSafeEqual ( 'not a buffer' , Buffer . from ( [ 1 , 2 ] ) ) ;
28- } , / ^ T y p e E r r o r : F i r s t a r g u m e n t m u s t b e a b u f f e r $ / ,
29- 'should throw if the first argument is not a buffer' ) ;
30+ common . expectsError (
31+ ( ) => crypto . timingSafeEqual ( 'not a buffer' , Buffer . from ( [ 1 , 2 ] ) ) ,
32+ {
33+ code : 'ERR_INVALID_ARG_TYPE' ,
34+ type : TypeError ,
35+ message :
36+ 'The "a" argument must be one of type Buffer, TypedArray, or DataView'
37+ }
38+ ) ;
3039
31- assert . throws ( function ( ) {
32- crypto . timingSafeEqual ( Buffer . from ( [ 1 , 2 ] ) , 'not a buffer' ) ;
33- } , / ^ T y p e E r r o r : S e c o n d a r g u m e n t m u s t b e a b u f f e r $ / ,
34- 'should throw if the second argument is not a buffer' ) ;
40+ common . expectsError (
41+ ( ) => crypto . timingSafeEqual ( Buffer . from ( [ 1 , 2 ] ) , 'not a buffer' ) ,
42+ {
43+ code : 'ERR_INVALID_ARG_TYPE' ,
44+ type : TypeError ,
45+ message :
46+ 'The "b" argument must be one of type Buffer, TypedArray, or DataView'
47+ }
48+ ) ;
0 commit comments