From 4dc0a928fe011546d909a1ff17616ddeb04e069a Mon Sep 17 00:00:00 2001 From: David Snelling Date: Wed, 15 Jul 2026 12:46:33 -0700 Subject: [PATCH] test: tolerant timing assertion in the execution-time measure test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setTimeout can fire a few ms early under load (timer coalescing) — a 10ms sleep measured 9ms and failed the >=10 assertion, tripping a release gate. Sleep 25ms, assert >=20: the test verifies time is MEASURED, not the OS timer's precision. --- tests/transaction/TransactionManager.unit.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/transaction/TransactionManager.unit.test.ts b/tests/transaction/TransactionManager.unit.test.ts index 5ffee866..cc477483 100644 --- a/tests/transaction/TransactionManager.unit.test.ts +++ b/tests/transaction/TransactionManager.unit.test.ts @@ -105,14 +105,17 @@ describe('TransactionManager', () => { const result = await manager.executeTransactionWithResult(async (tx) => { tx.addOperation({ execute: async () => { - await new Promise(resolve => setTimeout(resolve, 10)) + await new Promise(resolve => setTimeout(resolve, 25)) return async () => {} } }) return 'done' }) - expect(result.executionTimeMs).toBeGreaterThanOrEqual(10) + // Timer coalescing can fire a setTimeout up to a few ms EARLY under + // load, so assert well below the sleep — this tests that time is + // MEASURED, not the OS timer's precision. + expect(result.executionTimeMs).toBeGreaterThanOrEqual(20) }) })