Skip to content

Commit e947247

Browse files
committed
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: #35586
1 parent bcb1964 commit e947247

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

test/parallel/parallel.status

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ test-worker-memory: PASS,FLAKY
2727
test-worker-message-port-transfer-terminate: PASS,FLAKY
2828

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

3331
[$system==macos]
3432

test/parallel/test-webcrypto-encrypt-decrypt-aes.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,12 @@ async function testDecrypt({ keyBuffer, algorithm, result }) {
9696
const variations = [];
9797

9898
passing.forEach((vector) => {
99-
variations.push(testEncrypt(vector));
100-
variations.push(testEncryptNoEncrypt(vector));
101-
variations.push(testEncryptNoDecrypt(vector));
102-
variations.push(testEncryptWrongAlg(vector, 'AES-CTR'));
99+
variations.push(testEncrypt(Object.assign({}, vector)));
100+
variations.push(testEncryptNoEncrypt(Object.assign({}, vector)));
101+
variations.push(testEncryptNoDecrypt(Object.assign({}, vector)));
102+
variations.push(
103+
testEncryptWrongAlg(Object.assign({}, vector), 'AES-CTR')
104+
);
103105
});
104106

105107
failing.forEach((vector) => {

0 commit comments

Comments
 (0)