Skip to content

Commit

Permalink
test: refactor test-crypto-timing-safe-equal
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
targos authored and addaleax committed Dec 5, 2016
1 parent 0bdd5ca commit 0ccb2c3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/sequential/test-crypto-timing-safe-equal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ assert.strictEqual(

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

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

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

0 comments on commit 0ccb2c3

Please sign in to comment.