-
Hello, everyone, I'm currently going throuh the Invariant part of the course and I got a question regarding the execution order of functions when using invariant testing. My question is about this function function statefulFuzz_testInvariantBreakHandler() public {
vm.startPrank(owner);
-> handlerStatefulFuzzCatches.withdrawToken(mockUSDC);
-> handlerStatefulFuzzCatches.withdrawToken(yeildERC20);
vm.stopPrank();
assert(mockUSDC.balanceOf(address(handlerStatefulFuzzCatches)) == 0);
assert(yeildERC20.balanceOf(address(handlerStatefulFuzzCatches)) == 0);
assert(mockUSDC.balanceOf(owner) == startingAmount);
assert(yeildERC20.balanceOf(owner) == startingAmount);
} My question revolves around the order in which
Essentially, I'm trying to understand if the specified Thank you in advance for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey @wildanvin , i could go on and on explaining the execution orders of functions when using invariant testing but honestly what would be of more value to you is to set the number of runs to 1 and run the test, That would make it so the fuzzer runs once and you should use the |
Beta Was this translation helpful? Give feedback.
-
Awesome, I love that you see with your own eyes, instead of me sending just some text to explain. wish you the best on your knowledge journey |
Beta Was this translation helpful? Give feedback.
Yes you are rigth, I forgot about the -vvvvv option in foundry... The withdrawToken functions are called at the beginning of the test, and then the fuzzer attempts to break the invariants by calling other functions specified in the handler. The process is basically as follows:
statefulFuzz_testInvariantBreakHandler
function is called (executing everything on it).Basically, at step 1 we are withdrawing everything that the Handler (probably) deposited. Nice.