Skip to content

Commit 8ee236f

Browse files
樋口 彰italoacasas
樋口 彰
authored andcommitted
test: improve crypto coverage
* check exception when ECDH curve is undefined * check exception when getPublicKey format is invalid PR-URL: #11279 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent add7625 commit 8ee236f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/parallel/test-crypto-dh.js

+9
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ let firstByte = ecdh1.getPublicKey('buffer', 'compressed')[0];
182182
assert(firstByte === 2 || firstByte === 3);
183183
firstByte = ecdh1.getPublicKey('buffer', 'hybrid')[0];
184184
assert(firstByte === 6 || firstByte === 7);
185+
// format value should be string
186+
assert.throws(() => {
187+
ecdh1.getPublicKey('buffer', 10);
188+
}, /^TypeError: Bad format: 10$/);
185189

186190
// ECDH should check that point is on curve
187191
const ecdh3 = crypto.createECDH('secp256k1');
@@ -277,3 +281,8 @@ ecdh5.setPrivateKey(cafebabeKey, 'hex');
277281
// Verify object state did not change.
278282
assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey);
279283
});
284+
285+
// invalid test: curve argument is undefined
286+
assert.throws(() => {
287+
crypto.createECDH();
288+
}, /^TypeError: "curve" argument should be a string$/);

0 commit comments

Comments
 (0)