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 <rtrott@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
targos authored and addaleax committed Dec 8, 2016
1 parent b93c3d8 commit 0605c74
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/sequential/test-crypto-timing-safe-equal.js
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 0605c74

Please sign in to comment.