Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2021-02-01 04:06:25 +0300
committerDanielle Adams <adamzdanielle@gmail.com>2021-02-16 17:12:45 +0300
commit9dac99a11a388dd166380b23cf92bcf48b71b28d (patch)
treeaf190d65377b9ae61b57ac740ccac910852ef41a /test
parentdc38dd2c6fa2af3fd423d88092c7f31b00a28e6b (diff)
crypto: fix and simplify prime option validation
PR-URL: https://github.com/nodejs/node/pull/37164 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-crypto-prime.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/parallel/test-crypto-prime.js b/test/parallel/test-crypto-prime.js
index 27f34adea36..f51b091f536 100644
--- a/test/parallel/test-crypto-prime.js
+++ b/test/parallel/test-crypto-prime.js
@@ -71,6 +71,28 @@ const pCheckPrime = promisify(checkPrime);
});
});
+{
+ // Negative BigInts should not be converted to 0 silently.
+
+ assert.throws(() => generatePrime(20, { add: -1n }, common.mustNotCall()), {
+ code: 'ERR_OUT_OF_RANGE',
+ message: 'The value of "options.add" is out of range. It must be >= 0. ' +
+ 'Received -1n'
+ });
+
+ assert.throws(() => generatePrime(20, { rem: -1n }, common.mustNotCall()), {
+ code: 'ERR_OUT_OF_RANGE',
+ message: 'The value of "options.rem" is out of range. It must be >= 0. ' +
+ 'Received -1n'
+ });
+
+ assert.throws(() => checkPrime(-1n, common.mustNotCall()), {
+ code: 'ERR_OUT_OF_RANGE',
+ message: 'The value of "candidate" is out of range. It must be >= 0. ' +
+ 'Received -1n'
+ });
+}
+
generatePrime(80, common.mustSucceed((prime) => {
assert(checkPrimeSync(prime));
checkPrime(prime, common.mustSucceed((result) => {