-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
T-bugType: bugType: bug
Description
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.
Metadata
Metadata
Assignees
Labels
T-bugType: bugType: bug
Type
Projects
Status
Done