forge invariant test not fuzzing functions #101
-
I am writing invariant tests using a handler contract in foundry. However, for some reason, the handler contract is not fuzzing (I know because when I run contract Invariant is StdInvariant, Test {
Handler handler;
//additional logic ...
function setUp() public {
handler = new Handler(pool);
//additional logic ...
bytes4[] memory _selectors = new bytes4[](4);
_selectors[0] = handler.deposit.selector;
_selectors[1] = handler.swap.selector;
targetSelector(FuzzSelector({ addr: address(handler), selectors: _selectors}));
targetContract(address(handler));
}
function assertSomething() {
//logic ...
} Functions in handler contract: //deposit
function deposit(uint256 approvedAndDepositedToken, uint256 approvedAndDepositedWeth) public {
//logic ...
}
//swap
function swap(uint256 swapAmt) public {
//logic ...
} This is my output: Why are the functions in my handler contract not fuzzing (maybe not even running at all)? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I figured it out. The problem was the array length I specified was too large (4). The space of the array I specified is not the amount that I actually used.
I had to change the code from: bytes4[] memory selectors = new bytes4[](4);
bytes4[] memory selectors = new bytes4[](2); Because I only had 2 functions to fuzz call. |
Beta Was this translation helpful? Give feedback.
I figured it out. The problem was the array length I specified was too large (4). The space of the array I specified is not the amount that I actually used.
I had to change the code from:
Because I only had 2 functions to fuzz call.