1'use strict'; 2const common = require('../common'); 3if (!common.hasCrypto) 4 common.skip('missing crypto'); 5 6const assert = require('assert'); 7const crypto = require('crypto'); 8 9assert.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); 18assert.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); 27