test: overlap SLH-DSA signature checks

Start each asynchronous signature before the synchronous checks for the
same algorithm. Keep every sign, verify, and invalid-digest assertion,
with only one asynchronous signature outstanding. This reduces elapsed
time when CPU capacity is available without reducing coverage.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/65980
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
This commit is contained in:
Filip Skokan authored and Antoine du Hamel committed 2026-09-25 18:01:48 +02:00
1 parent bfdf20729d
commit a578933da0
1 file changed
+6 -3
@@ -13,6 +13,9 @@ import { promisify } from 'node:util';
import { randomBytes, sign, verify } from 'node:crypto';
import fixtures from '../common/fixtures.js';
const pSign = promisify(sign);
const pVerify = promisify(verify);
function getKeyFileName(type, suffix) {
return `${type.replaceAll('-', '_')}_${suffix}.pem`;
}
@@ -37,6 +40,8 @@ for (const [asymmetricKeyType, sigLen] of [
};
const data = randomBytes(32);
// Start the async signature before the sync work to overlap the two.
const signaturePromise = pSign(undefined, data, keys.private);
// sync
{
@@ -48,9 +53,7 @@ for (const [asymmetricKeyType, sigLen] of [
// async
{
const pSign = promisify(sign);
const pVerify = promisify(verify);
const signature = await pSign(undefined, data, keys.private);
const signature = await signaturePromise;
assert.strictEqual(signature.byteLength, sigLen);
assert.strictEqual(await pVerify(undefined, randomBytes(32), keys.public, signature), false);
assert.strictEqual(await pVerify(undefined, data, keys.public, signature), true);