Skip to content

Commit

Permalink
test: fix flaky test-webcrypto-encrypt-decrypt-aes
Browse files Browse the repository at this point in the history
Use Object.assign() to make shallow copies of the object passed to the
test functions. The test functions are passed to Promise.all() so
execution order is not guaranteed. So using the same object in all of
them is a race condition where one test can have side effects in
another.

Fixes: nodejs#35586
  • Loading branch information
Trott committed Feb 15, 2021
1 parent bcb1964 commit e947247
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ test-worker-memory: PASS,FLAKY
test-worker-message-port-transfer-terminate: PASS,FLAKY

[$system==linux]
# https://github.com/nodejs/node/issues/35586
test-webcrypto-encrypt-decrypt-aes: PASS,FLAKY

[$system==macos]

Expand Down
10 changes: 6 additions & 4 deletions test/parallel/test-webcrypto-encrypt-decrypt-aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ async function testDecrypt({ keyBuffer, algorithm, result }) {
const variations = [];

passing.forEach((vector) => {
variations.push(testEncrypt(vector));
variations.push(testEncryptNoEncrypt(vector));
variations.push(testEncryptNoDecrypt(vector));
variations.push(testEncryptWrongAlg(vector, 'AES-CTR'));
variations.push(testEncrypt(Object.assign({}, vector)));
variations.push(testEncryptNoEncrypt(Object.assign({}, vector)));
variations.push(testEncryptNoDecrypt(Object.assign({}, vector)));
variations.push(
testEncryptWrongAlg(Object.assign({}, vector), 'AES-CTR')
);
});

failing.forEach((vector) => {
Expand Down

0 comments on commit e947247

Please sign in to comment.