Skip to content

forge test: selector that is not targeted is called in invariant test #11006

@0xalpharush

Description

@0xalpharush

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge Version: 1.2.3-nightly Commit SHA: aa3cc0f Build Timestamp: 2025-07-12T06:02:08.303595000Z (1752300128) Build Profile: maxperf

What version of Foundryup are you on?

No response

What command(s) is the bug in?

forge test

Operating System

None

Describe the bug

I observed on this codebase that mine is being called despite not being added to the targetSelectors (it is only added in DynamicInvariantTest.sol but not StaticInvariantTest.sol). @MathisGD seemed to think this is unexpected. I'm not sure if parent contract setup would be overriding it
https://github.com/morpho-org/morpho-blue/blob/c75dc8244032b30768217599ae8f1c11e9b43a35/test/forge/InvariantTest.sol#L21-L21

$ FOUNDRY_INVARIANT_TIMEOUT=60  FOUNDRY_INVARIANT_RUNS=10000000 forge test --match-test invariantHealth
[FAIL: <empty revert data>]
        [Sequence] (original: 221, shrunk: 4)
                sender=0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D addr=[test/forge/invariant/StaticInvariantTest.sol:StaticInvariantTest]0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 calldata=supplyAssetsOnBehalfNoRevert(uint256,uint256,uint256) args=[143644804196377601180493606465125 [1.436e32], 2387001063984533184672501806564016805421522348552258002 [2.387e54], 26425663378786729231376736458046134880238791620212394118 [2.642e55]]
                sender=0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D addr=[test/forge/invariant/StaticInvariantTest.sol:StaticInvariantTest]0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 calldata=supplyCollateralOnBehalfNoRevert(uint256,uint256,uint256) args=[15776064102668740315174263351797424840303214061274268393943129069 [1.577e64], 1145014072366159318135980566333394292438848558065796580 [1.145e54], 580276607467535235034411965006757667834469986129740784 [5.802e53]]
                sender=0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D addr=[test/forge/invariant/StaticInvariantTest.sol:StaticInvariantTest]0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 calldata=borrowAssetsOnBehalfNoRevert(uint256,uint256,uint256,address) args=[2289731442743048336023665587 [2.289e27], 115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77], 23477893049651810414146 [2.347e22], 0xfF300FefA2210c47Fc7Ef76c674F34B76793101d]
                sender=0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D addr=[test/forge/invariant/StaticInvariantTest.sol:StaticInvariantTest]0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 calldata=mine(uint256) args=[45730845516466726098616970903265183475320263733589484087395164 [4.573e61]]
 invariantHealthy() (runs: 3, calls: 768, reverts: 0)
$ git rev-parse HEAD
c75dc8244032b30768217599ae8f1c11e9b43a35

Maybe it is related to this?
#10274
https://github.com/morpho-org/morpho-blue/blob/c75dc8244032b30768217599ae8f1c11e9b43a35/test/forge/InvariantTest.sol#L20

cc @MathisGD

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Completed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions