diff --git a/yarn-project/world-state/src/native/native_world_state.test.ts b/yarn-project/world-state/src/native/native_world_state.test.ts index 5acafa7d67b6..8b36a4f17c50 100644 --- a/yarn-project/world-state/src/native/native_world_state.test.ts +++ b/yarn-project/world-state/src/native/native_world_state.test.ts @@ -14,7 +14,7 @@ import { timesAsync } from '@aztec/foundation/collection'; import { randomBytes } from '@aztec/foundation/crypto/random'; import { Fr } from '@aztec/foundation/curves/bn254'; import { EthAddress } from '@aztec/foundation/eth-address'; -import { sleep } from '@aztec/foundation/sleep'; +import { retryUntil } from '@aztec/foundation/retry'; import type { SiblingPath } from '@aztec/foundation/trees'; import { PublicDataWrite } from '@aztec/stdlib/avm'; import { L2Block } from '@aztec/stdlib/block'; @@ -960,7 +960,10 @@ describe('NativeWorldState', () => { await ws.unwindBlocks(BlockNumber.fromBigInt(2n)); await expect(delayedFork.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, 0n)).rejects.toThrow('Fork not found'); - await sleep(closeDelayMs * 3); + // The delayed close fires after closeDelayMs and then asynchronously deletes the per-fork queue entry + // once its DELETE_FORK round-trip settles. Under a loaded CI grind that cleanup can take longer than a + // fixed sleep, so wait for it deterministically instead of racing closeDelayMs * 3. + await retryUntil(() => !(ws as any).instance.queues.has(forkId), 'delayed-close fork queue cleanup', 30, 0.1); expect(warnSpy).not.toHaveBeenCalled(); expect((ws as any).instance.queues.has(forkId)).toBe(false);