Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invariant Testing: Fail on Revert Regression bug #6082

Closed
2 tasks done
77abe77 opened this issue Oct 22, 2023 · 0 comments · Fixed by #6199
Closed
2 tasks done

Invariant Testing: Fail on Revert Regression bug #6082

77abe77 opened this issue Oct 22, 2023 · 0 comments · Fixed by #6199
Labels
T-bug Type: bug

Comments

@77abe77
Copy link

77abe77 commented Oct 22, 2023

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (619f3c5 2023-10-22T00:19:08.867786000Z)

What command(s) is the bug in?

forge test -vvv --mc ForgeInvariantBug

Operating System

macOS (Intel)

Describe the bug

Simple contract: NOTE: this contract was used to showcase another bug, however I cant even replicate that bug bc this one is blocking that.

// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.17;

import {Test} from "forge-std/Test.sol";


contract A {
    function a_shouldnt_be_tested() external {
        revert();
    }

    function b_shouldnt_be_tested() external {
        revert();
    }
}

contract Handler {
    function a_should_be_tested() external {
        new A();
    }

}

contract ForgeInvariantBug is Test {
    Handler h;
    function setUp() external {
        h = new Handler();

        bytes4[] memory selectors = new bytes4[](1);
        selectors[0] = Handler.a_should_be_tested.selector;
        targetSelector(FuzzSelector({
            addr: address(h),
            selectors: selectors
        }));
    }

    /// forge-config: default.invariant.runs = 3
    /// forge-config: default.invariant.depth = 10
    /// forge-config: default.invariant.fail-on-revert = true
    /// forge-config: default.invariant.call-override = false
    function invariant_a() external {
        assertTrue(true);
    }
}

Testing Result:

Running 1 test for test/ForgeInvariantBug.t.sol:ForgeInvariantBug
[PASS] invariant_a() (runs: 1, calls: 2, reverts: 1)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.37ms

The test should be expected to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
1 participant