Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add error validation to assert.throws calls #11253

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions test/pummel/test-crypto-dh.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,32 @@ if (!common.hasCrypto) {
return;
}

assert.throws(function() {
crypto.getDiffieHellman('unknown-group');
});
assert.throws(function() {
crypto.getDiffieHellman('modp1').setPrivateKey('');
});
assert.throws(function() {
crypto.getDiffieHellman('modp1').setPublicKey('');
});
assert.throws(
function() {
crypto.getDiffieHellman('unknown-group');
},
/^Error: Unknown group$/,
'crypto.getDiffieHellman(\'unknown-group\') ' +
'failed to throw the expected error.'
);
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.'
);

const hashes = {
modp1: '630e9acd2cc63f7e80d8507624ba60ac0757201a',
Expand Down