From 410ce2164ece66a6b8467e0c0bf541c095c6ac50 Mon Sep 17 00:00:00 2001 From: Leko Date: Mon, 18 Dec 2017 15:44:00 +0900 Subject: [PATCH] test: increase diffie-hellman test coverage PR-URL: https://github.com/nodejs/node/pull/17728 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Jon Moss --- test/parallel/test-crypto-dh.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js index d55540dd88035c..bb3f0044f8d812 100644 --- a/test/parallel/test-crypto-dh.js +++ b/test/parallel/test-crypto-dh.js @@ -22,6 +22,28 @@ assert.strictEqual(secret2.toString('base64'), secret1); assert.strictEqual(dh1.verifyError, 0); assert.strictEqual(dh2.verifyError, 0); +{ + const DiffieHellman = crypto.DiffieHellman; + const dh = DiffieHellman(p1, 'buffer'); + assert(dh instanceof DiffieHellman, 'DiffieHellman is expected to return a ' + + 'new instance when called without `new`'); +} + +{ + const DiffieHellmanGroup = crypto.DiffieHellmanGroup; + const dhg = DiffieHellmanGroup('modp5'); + assert(dhg instanceof DiffieHellmanGroup, 'DiffieHellmanGroup is expected ' + + 'to return a new instance when ' + + 'called without `new`'); +} + +{ + const ECDH = crypto.ECDH; + const ecdh = ECDH('prime256v1'); + assert(ecdh instanceof ECDH, 'ECDH is expected to return a new instance ' + + 'when called without `new`'); +} + [ [0x1, 0x2], () => { },