More specific error messages for "EvmError"
Component
Forge
Describe the feature you would like
To test certain EVM errors such as block gas limit overflows, we have to expect an empty revert like this:
vm.expectRevert(bytes(""));
This is also documented in the Foundry Book, so it's all clear from a user documentation perspective. But this is not cool from a user experience point of view.
Ideally, Foundry would catch such EVM errors and throw a more specific error message, so that:
- Users have better guarantees that their tests are passing for the right reason
- Debugging is easier
Additional context
I can see the following logs in the traces if I pass the -vvvv flag:
Traces:
[2157781646] CreateWithDeltas__ProTest::testCannotCreateWithDeltas__LoopCalculationOverflowsBlockGasLimit()
├─ [0] VM::expectRevert(0x)
│ └─ ← ()
└─ ← "EvmError: OutOfGas
Therefore, it should be in principle possible to catch this error and relay it to end users, so that tests could be written like this:
vm.expectRevert(bytes("EvmError: OutOfGas"));
IIUC there's two things being requested here:
- More specific error messages thrown. In https://github.com/foundry-rs/foundry/issues/1387 we aggregated most/all EVM errors to handle and I'm not sure where that left off. @gakonst are we tracking all the possible errors to handle somewhere?
- Being able to specify/catch all those errors with
vm.expectRevert
I agree both of these are worth implementing
I wasn't strictly requesting your point 1 as a feature - I have sort of taken it as an assumption that Foundry already aggregates most/ all EVM errors internally.
It's point 2 that I was mainly interested in - to be able to catch all of those errors with vm.expectRevert.
@PaulRBerg is this still of interest? thanks!
@grandizzy yes
Would love to see this feature