node/test/parallel/test-crypto-modp1-error.js
Joyee Cheung 5d0d611eb0
test: split test-crypto-dh.js
Split test-crypto-dh.js so that it is less likely to timeout on
less powerful bots.

PR-URL: https://github.com/nodejs/node/pull/40451
Refs: https://github.com/nodejs/reliability/issues/86
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-10-19 15:36:42 +08:00

27 lines
790 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
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.'
);