Skip to content

[contracts] fork happy-path test bundles 5 markets in one loop — first failure masks remaining results #272

@obchain

Description

@obchain

Refs #53

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

Code:
for (uint256 i = 0; i < markets.length; i++) {
_assertHappyPath(markets[i]);
}

Problem:
All 5 market pairs are exercised inside a single test function via a for-loop. If _assertHappyPath(markets[2]) reverts or fails an assertion, Foundry aborts the test and markets[3] and markets[4] never run. CI output shows one failure with one market name. The developer cannot tell from CI whether the failure is isolated or systemic across multiple markets.

This is especially problematic for a fork test suite because market-specific failures (e.g., Aave pausing one reserve, a vToken address change) will look identical to systemic failures from the CI output.

Fix:
Replace the loop with five individual test functions:

function test_fork_happyPath_usdt_usdc() public { _assertHappyPath(_markets()[0]); }
function test_fork_happyPath_usdt_btcb() public { _assertHappyPath(_markets()[1]); }
function test_fork_happyPath_usdc_btcb() public { _assertHappyPath(_markets()[2]); }
function test_fork_happyPath_usdt_eth() public { _assertHappyPath(_markets()[3]); }
function test_fork_happyPath_btcb_usdt() public { _assertHappyPath(_markets()[4]); }

Foundry will report granular pass/fail per market and continue running remaining tests even after one market fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions