test: tolerant timing assertion in the execution-time measure test

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.
This commit is contained in:
David Snelling 2026-07-15 12:46:33 -07:00
parent d1ecee10f0
commit 4dc0a928fe

View file

@ -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)
})
})