From 463a01630d68fb96abdc2af5a1f3c90f8069b8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 29 Nov 2016 20:35:30 +0100 Subject: [PATCH] test: refactor test-crypto-timing-safe-equal Add RegExp arguments to throws assertions. --- test/sequential/test-crypto-timing-safe-equal.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-crypto-timing-safe-equal.js b/test/sequential/test-crypto-timing-safe-equal.js index 6e15a577188cc3..9c4265a672cc0f 100644 --- a/test/sequential/test-crypto-timing-safe-equal.js +++ b/test/sequential/test-crypto-timing-safe-equal.js @@ -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');