From e9472477ab974112d3eeb9dd39b13eac464d2b7f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 14 Feb 2021 16:26:23 -0800 Subject: [PATCH] test: fix flaky test-webcrypto-encrypt-decrypt-aes 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: https://github.com/nodejs/node/issues/35586 --- test/parallel/parallel.status | 2 -- test/parallel/test-webcrypto-encrypt-decrypt-aes.js | 10 ++++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 8f886c76333e3b..574bc1c9fe13a3 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -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] diff --git a/test/parallel/test-webcrypto-encrypt-decrypt-aes.js b/test/parallel/test-webcrypto-encrypt-decrypt-aes.js index 38d2b70bcb0567..6cec58fdd018c2 100644 --- a/test/parallel/test-webcrypto-encrypt-decrypt-aes.js +++ b/test/parallel/test-webcrypto-encrypt-decrypt-aes.js @@ -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) => {