medium10 pts · first answer countstesting-and-fuzzingfoundry
expectRevert in the wrong place
This Foundry test fails with "next call did not revert as expected" even though withdraw reverts for non-owners. Why?
function test_RevertWhen_NotOwner() public {
vm.prank(attacker);
vault.withdraw(1 ether);
vm.expectRevert(Vault.NotOwner.selector);
}Discussion 0
Join free to post in the discussion.
Related questions
- Where to try a deploymentBlockchain Developer
- Foundry's local nodeBlockchain Developer
- Calling as another address in a testBlockchain Developer
- Seeing why a Foundry test failedBlockchain Developer
- Fuzz tests in FoundryBlockchain Developer
- Testing against real protocolsBlockchain Developer
- Invariant testsBlockchain Developer
- Testing a 7-day lockBlockchain Developer