From 92fb7dd818708c03140ffe0b1539ee337e1005d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Thu, 31 Aug 2023 21:33:22 +0200 Subject: [PATCH] test: simplify test-crypto-dh-group-setters I can't tell why the test was written that way in the first place, but it seems sufficient to check that setPrivateKey and setPublicKey are both undefined. Refs: https://github.com/nodejs/node-v0.x-archive/pull/2638 Refs: https://github.com/nodejs/node/pull/11253 PR-URL: https://github.com/nodejs/node/pull/49404 Reviewed-By: Filip Skokan Reviewed-By: Luigi Pinca --- test/parallel/test-crypto-dh-group-setters.js | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-crypto-dh-group-setters.js b/test/parallel/test-crypto-dh-group-setters.js index 38f78c158704b2..7c774111952ead 100644 --- a/test/parallel/test-crypto-dh-group-setters.js +++ b/test/parallel/test-crypto-dh-group-setters.js @@ -6,21 +6,8 @@ if (!common.hasCrypto) const assert = require('assert'); const crypto = require('crypto'); -assert.throws( - function() { - crypto.getDiffieHellman('modp1').setPrivateKey(''); - }, - new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' + - 'setPrivateKey is not a function$'), - 'crypto.getDiffieHellman(\'modp1\').setPrivateKey(\'\') ' + - 'failed to throw the expected error.' -); -assert.throws( - function() { - crypto.getDiffieHellman('modp1').setPublicKey(''); - }, - new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' + - 'setPublicKey is not a function$'), - 'crypto.getDiffieHellman(\'modp1\').setPublicKey(\'\') ' + - 'failed to throw the expected error.' -); +// Unlike DiffieHellman, DiffieHellmanGroup does not have any setters. +const dhg = crypto.getDiffieHellman('modp1'); +assert.strictEqual(dhg.constructor, crypto.DiffieHellmanGroup); +assert.strictEqual(dhg.setPrivateKey, undefined); +assert.strictEqual(dhg.setPublicKey, undefined);