From 6c74dbfe6eb3491d3c6ca80657e543f0d97405bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Tue, 29 Aug 2023 19:17:53 +0000 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 --- 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);