MCPcopy Index your code
hub / github.com/nodejs/node / testGenerateKeysChangesKeys

Function testGenerateKeysChangesKeys

test/parallel/test-crypto-dh-generate-keys.js:24–41  ·  view source on GitHub ↗
(setup, expected)

Source from the content-addressed store, hash-verified

22 }
23
24 function testGenerateKeysChangesKeys(setup, expected) {
25 const dh = crypto.createDiffieHellman(size);
26 setup(dh);
27 const firstPublicKey = unlessInvalidState(() => dh.getPublicKey());
28 const firstPrivateKey = unlessInvalidState(() => dh.getPrivateKey());
29 dh.generateKeys();
30 const secondPublicKey = dh.getPublicKey();
31 const secondPrivateKey = dh.getPrivateKey();
32 function changed(shouldChange, first, second) {
33 if (shouldChange) {
34 assert.notDeepStrictEqual(first, second);
35 } else {
36 assert.deepStrictEqual(first, second);
37 }
38 }
39 changed(expected.includes('public'), firstPublicKey, secondPublicKey);
40 changed(expected.includes('private'), firstPrivateKey, secondPrivateKey);
41 }
42
43 // Both the private and the public key are missing: generateKeys() generates both.
44 testGenerateKeysChangesKeys(() => {

Callers 1

Calls 4

unlessInvalidStateFunction · 0.85
changedFunction · 0.85
includesMethod · 0.80
setupFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…