From 017a836f0a3469cf251b6636c6a4720c96124409 Mon Sep 17 00:00:00 2001 From: Teddy Knox Date: Wed, 28 Oct 2026 16:02:13 -0400 Subject: [PATCH] contracts-bedrock: search fork-safe start in findLatestGames fuzz test testFuzz_findLatestGames_correctAmount_succeeds searched from index _numGames - 1. On a fork the factory already holds the chain's own games, so that index points at a historical game, not one the test created. On ink-mainnet games 0-4 are all type 1, so any input with _n > 0 returned no type-0 games and failed (counterexample [29, 43, 9]). OP Mainnet's first games are type 0, which hid the bug there. Search from the factory's newest game instead. Without a fork the start index is unchanged. Co-Authored-By: Claude Opus 5.5 --- .../contracts-bedrock/test/dispute/DisputeGameFactory.t.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol b/packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol index 33db6d0b653..5e9b4150371 100644 --- a/packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol +++ b/packages/contracts-bedrock/test/dispute/DisputeGameFactory.t.sol @@ -853,8 +853,10 @@ contract DisputeGameFactory_FindLatestGames_Test is DisputeGameFactory_TestInit disputeGameFactory.create(GameType.wrap(gameType), Claim.wrap(bytes32(i)), abi.encode(i)); } - // Ensure that the correct number of games are returned. - uint256 start = _numGames == 0 ? 0 : _numGames - 1; + // Ensure that the correct number of games are returned. Search from the newest game: + // on a fork the factory already holds the chain's own games before the new ones. + uint256 gameCount = disputeGameFactory.gameCount(); + uint256 start = gameCount == 0 ? 0 : gameCount - 1; IDisputeGameFactory.GameSearchResult[] memory games = disputeGameFactory.findLatestGames(GameType.wrap(0), start, _n); assertEq(games.length, _n);