Skip to content

Commit cf5ba30

Browse files
committed
fixup! test: consolidate crypto provider cache coverage
Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex
1 parent 6515be8 commit cf5ba30

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

‎test/parallel/test-crypto-provider-cache.js‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ function withMacCacheSetter(fixtures, toggle) {
241241
}
242242

243243
if (!isMainThread) {
244-
let lists = checkLists();
245-
function reply(phase) {
244+
function reply(phase, lists) {
246245
parentPort.postMessage({
247246
phase,
248247
lists,
@@ -251,14 +250,18 @@ if (!isMainThread) {
251250
});
252251
}
253252
if (workerData.listsOnly) {
254-
reply('fresh');
253+
parentPort.once('message', common.mustCall(() => {
254+
reply('fresh', checkLists());
255+
}));
256+
parentPort.postMessage('ready');
255257
} else {
258+
let lists = checkLists();
256259
const fixtures = createFixtures(lists);
257260
assert.throws(() => setFips(1), {
258261
code: 'ERR_WORKER_UNSUPPORTED_OPERATION',
259262
});
260263
assert.deepStrictEqual(checkLists(), lists);
261-
reply('warm');
264+
reply('warm', lists);
262265
parentPort.on('message', common.mustCallAtLeast(({ phase, available }) => {
263266
if (phase === 'done') {
264267
parentPort.close();
@@ -269,7 +272,7 @@ if (!isMainThread) {
269272
const next = checkLists();
270273
if (phase === 'unchanged') assert.deepStrictEqual(next, lists);
271274
lists = next;
272-
reply(phase);
275+
reply(phase, lists);
273276
}));
274277
}
275278
} else {
@@ -285,6 +288,7 @@ if (!isMainThread) {
285288
return;
286289
}
287290
let worker;
291+
let freshWorker;
288292
try {
289293
const defaultLists = checkLists();
290294
const fixtures = createFixtures(defaultLists);
@@ -312,14 +316,23 @@ if (!isMainThread) {
312316
assert.deepStrictEqual(checkLists(), defaultLists);
313317
await exchange('unchanged', defaultLists);
314318

315-
withMacCacheSetter(fixtures, () => setFips(1));
316-
// A cold environment provides independent expectations for both native
317-
// and JavaScript caches, including when no FIPS provider is installed.
318-
const freshWorker = new Worker(__filename, {
319+
// AIX uses OpenSSL entropy when initializing a worker's V8 isolate.
320+
// Start it before enabling FIPS properties, which can succeed without a
321+
// FIPS provider, but defer its first cache lookup until after the toggle.
322+
freshWorker = new Worker(__filename, {
319323
workerData: { cryptoCacheTest: true, listsOnly: true },
320324
});
325+
freshWorker.on('error', common.mustNotCall());
321326
const freshExit = once(freshWorker, 'exit');
322-
const [fresh] = await once(freshWorker, 'message');
327+
const [ready] = await once(freshWorker, 'message');
328+
assert.strictEqual(ready, 'ready');
329+
330+
withMacCacheSetter(fixtures, () => setFips(1));
331+
// A cold environment provides independent expectations for both native
332+
// and JavaScript caches, including when no FIPS provider is installed.
333+
const freshResponse = once(freshWorker, 'message');
334+
freshWorker.postMessage('read');
335+
const [fresh] = await freshResponse;
323336
const [freshCode] = await freshExit;
324337
assert.strictEqual(freshCode, 0);
325338
const enabledLists = fresh.lists;
@@ -341,6 +354,8 @@ if (!isMainThread) {
341354
const [code] = await exitPromise;
342355
assert.strictEqual(code, 0);
343356
} finally {
357+
if (freshWorker !== undefined && freshWorker.threadId !== -1)
358+
await freshWorker.terminate();
344359
if (worker !== undefined && worker.threadId !== -1) await worker.terminate();
345360
setFips(originalFips);
346361
}

0 commit comments

Comments
 (0)