Skip to content

Commit 2a35782

Browse files
tniessenUlisesGascon
authored andcommitted
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: nodejs/node-v0.x-archive#2638 Refs: #11253 PR-URL: #49404 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 6740f3c commit 2a35782

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

test/parallel/test-crypto-dh-group-setters.js

+5-18
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,8 @@ if (!common.hasCrypto)
66
const assert = require('assert');
77
const crypto = require('crypto');
88

9-
assert.throws(
10-
function() {
11-
crypto.getDiffieHellman('modp1').setPrivateKey('');
12-
},
13-
new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' +
14-
'setPrivateKey is not a function$'),
15-
'crypto.getDiffieHellman(\'modp1\').setPrivateKey(\'\') ' +
16-
'failed to throw the expected error.'
17-
);
18-
assert.throws(
19-
function() {
20-
crypto.getDiffieHellman('modp1').setPublicKey('');
21-
},
22-
new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' +
23-
'setPublicKey is not a function$'),
24-
'crypto.getDiffieHellman(\'modp1\').setPublicKey(\'\') ' +
25-
'failed to throw the expected error.'
26-
);
9+
// Unlike DiffieHellman, DiffieHellmanGroup does not have any setters.
10+
const dhg = crypto.getDiffieHellman('modp1');
11+
assert.strictEqual(dhg.constructor, crypto.DiffieHellmanGroup);
12+
assert.strictEqual(dhg.setPrivateKey, undefined);
13+
assert.strictEqual(dhg.setPublicKey, undefined);

0 commit comments

Comments
 (0)