From bdfca60f11c0fd95a40a1d8a7dc22efe2f5991c4 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sun, 20 Sep 2026 09:12:05 +0200 Subject: [PATCH] test: deflake test-benchmark-crypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test mode reduces bufferSize to one, giving the random buffers a 1/256 chance of matching and failing the comparison count assertion. Use 256 bytes in test mode and force the first bytes to differ before timing. Remove the flaky designation. Fixes: https://github.com/nodejs/node/issues/52690 Signed-off-by: Filip Skokan Assisted-by: Codex PR-URL: https://github.com/nodejs/node/pull/66151 Fixes: https://github.com/nodejs/node/issues/58353 Reviewed-By: Matteo Collina Reviewed-By: Jake Yuesong Li Reviewed-By: Gürgün Dayıoğlu Reviewed-By: James M Snell Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- benchmark/crypto/timingSafeEqual.js | 4 ++++ test/benchmark/benchmark.status | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/benchmark/crypto/timingSafeEqual.js b/benchmark/crypto/timingSafeEqual.js index 475807dba4e..bd8962a3bdf 100644 --- a/benchmark/crypto/timingSafeEqual.js +++ b/benchmark/crypto/timingSafeEqual.js @@ -7,10 +7,14 @@ const { randomBytes, timingSafeEqual } = require('node:crypto'); const bench = common.createBenchmark(main, { n: [1e5], bufferSize: [10, 100, 200, 2_100, 22_023], +}, { + test: { bufferSize: 256 }, }); function main({ n, bufferSize }) { const bufs = [randomBytes(bufferSize), randomBytes(bufferSize)]; + // Ensure the buffers differ even if the random bytes are identical. + bufs[1][0] = bufs[0][0] ^ 1; bench.start(); let count = 0; for (let i = 0; i < n; i++) { diff --git a/test/benchmark/benchmark.status b/test/benchmark/benchmark.status index ea666f58a73..322a7191025 100644 --- a/test/benchmark/benchmark.status +++ b/test/benchmark/benchmark.status @@ -6,9 +6,6 @@ prefix benchmark [true] # This section applies to all platforms -# https://github.com/nodejs/node/issues/52690 -test-benchmark-crypto: PASS, FLAKY - [$system==win32] [$system==linux]