Open
Description
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
1.1.0-stable
What version of Foundryup are you on?
0.3.3
What command(s) is the bug in?
forge t
Operating System
None
Describe the bug
in a call following a expectEmit
, if a reverts happens before the event emission the test will fail with log != expected log
. It seems way more natural to fail with EvmError: Revert
for two reasons: nobody should be testing even emission on failing paths (events are not emitted if the call reverted), and reverts are "more important" than wrong log. Also the inconsistent behaviour if the event is emitted before the revert is weird (the event will not be emitted if the call reverts).
minimal example:
event Foo();
function revertingBefore() external {
revert();
emit Foo();
}
function revertingAfter() external {
emit Foo();
revert();
}
// this test fails with `log != expected log`
function testBefore() public {
vm.expectEmit();
emit Foo();
this.revertingBefore(); // reverting call
}
// this test fails with `EvmError: Revert`
function testAfter() public {
vm.expectEmit();
emit Foo();
this.revertingAfter(); // reverting call
}
Metadata
Metadata
Assignees
Type
Projects
Status
Backlog