Skip to content

Commit 0ccb2c3

Browse files
targosaddaleax
authored andcommitted
test: refactor test-crypto-timing-safe-equal
Add RegExp arguments to throws assertions. PR-URL: #9843 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Teddy Katz <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 0bdd5ca commit 0ccb2c3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/sequential/test-crypto-timing-safe-equal.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ assert.strictEqual(
2323

2424
assert.throws(function() {
2525
crypto.timingSafeEqual(Buffer.from([1, 2, 3]), Buffer.from([1, 2]));
26-
}, 'should throw when given buffers with different lengths');
26+
}, /^TypeError: Input buffers must have the same length$/,
27+
'should throw when given buffers with different lengths');
2728

2829
assert.throws(function() {
2930
crypto.timingSafeEqual('not a buffer', Buffer.from([1, 2]));
30-
}, 'should throw if the first argument is not a buffer');
31+
}, /^TypeError: First argument must be a buffer$/,
32+
'should throw if the first argument is not a buffer');
3133

3234
assert.throws(function() {
3335
crypto.timingSafeEqual(Buffer.from([1, 2]), 'not a buffer');
34-
}, 'should throw if the second argument is not a buffer');
36+
}, /^TypeError: Second argument must be a buffer$/,
37+
'should throw if the second argument is not a buffer');

0 commit comments

Comments
 (0)