Skip to content

Commit 607158a

Browse files
樋口 彰MylesBorins
樋口 彰
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 0164d92 commit 607158a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/parallel/test-crypto-dh.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ let firstByte = ecdh1.getPublicKey('buffer', 'compressed')[0];
170170
assert(firstByte === 2 || firstByte === 3);
171171
firstByte = ecdh1.getPublicKey('buffer', 'hybrid')[0];
172172
assert(firstByte === 6 || firstByte === 7);
173+
// format value should be string
174+
assert.throws(() => {
175+
ecdh1.getPublicKey('buffer', 10);
176+
}, /^TypeError: Bad format: 10$/);
173177

174178
// ECDH should check that point is on curve
175179
const ecdh3 = crypto.createECDH('secp256k1');
@@ -262,3 +266,8 @@ ecdh5.setPrivateKey(cafebabeKey, 'hex');
262266
// Verify object state did not change.
263267
assert.equal(ecdh5.getPrivateKey('hex'), cafebabeKey);
264268
});
269+
270+
// invalid test: curve argument is undefined
271+
assert.throws(() => {
272+
crypto.createECDH();
273+
}, /^TypeError: "curve" argument should be a string$/);

0 commit comments

Comments
 (0)