Skip to content

[contracts] fork tests use unpinned block — non-deterministic CI across runs #264

@obchain

Description

@obchain

Refs #53

File: contracts/test/CharonLiquidatorFork.t.sol, setUp() function

Problem:
setUp() calls vm.createSelectFork("bnb") with no block number argument. Foundry forks at the RPC's latest block. CI runs at different times fork different blocks. Aave V3 reserve state, vToken exchange rates, and token balances all change block-to-block. A test that passes today can fail in next week's CI run as conditions drift — or pass silently when it should fail.

The PR description acknowledges this ('unpinned block; BNB_HTTP_URL aliased as bnb in foundry.toml') but treats it as acceptable. It is not: non-deterministic tests are worse than no tests for regression detection.

PRD clause / invariant: Standard fork testing requirement. CLAUDE.md: forge test must pass reliably (gates must pass before any commit). A non-deterministic suite cannot satisfy this.

Impact:

  • Flaky CI — the 4/4 pass rate cited in the PR is only valid at the specific blocks tested by the author.
  • A broken fix merged later (e.g., wrong fee tier, wrong address) may pass on the forked block where it was tested but fail on the block CI uses.
  • No reproducible failure investigation: 'the test was passing yesterday' is the only debug signal.

Fix:
Choose a specific BSC mainnet block at which the Aave V3 pool is known-active and all 5 market vTokens are live. Pin the fork:

uint256 internal constant FORK_BLOCK = 39_000_000; // example — choose a verified block
vm.createSelectFork("bnb", FORK_BLOCK);

Document the block number in a comment with the date and reason for the choice. Update the block periodically in deliberate, reviewed PRs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions