You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating asserts about event logs with vm.expectRevert. However when the comparison fails the test gives insufficient partially incorrect feedback:
[FAIL. Reason: Expected an emit, but the call reverted instead. Ensure you're testing the happy path when using the `expectEmit` cheatcode.]
You get a hint at real the cause of the error (log mismatch) if you increase verbosity:
[FAIL. Reason: Expected an emit, but the call reverted instead. Ensure you're testing the happy path when using the `expectEmit` cheatcode.] testCorrect() (gas: 11332)
Traces:
[11332] MyTest::testCorrect()
├─ [0] VM::expectEmit(true, true, false, true)
│ └─ ← ()
├─ emit Values(a: 420)
├─ [1756] Emitter::plsEmit(69, 420)
│ ├─ emit Values()
│ └─ ← ()
└─ ← "Log != expected log"
The base fail message is however still incorrect. This is made more confusing by the fact that the trace seems to omit logging the parameters (a and b are missing)?
Expected Behavior
The fail message clearly states that the fail was due to a mismatching event
The event is displayed in full in the trace
The log != expect ... message is more specific indicating why the comparison failed:
No event was emitted (ideally also tells you if events were simply out-of-order)
Wrong event (topic0 mismatch)
The value of one of the fields is wrong
Type mismatch, this can be especially hard to debug with the current state (e.g. name match but field missing, type of fields mismatch, and hardest to notice currently: everything matches except indexed on some fields)
The text was updated successfully, but these errors were encountered:
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (dee4181 2023-10-30T00:17:30.403957319Z)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
The Example
Description
When creating asserts about event logs with
vm.expectRevert
. However when the comparison fails the test gives insufficient partially incorrect feedback:You get a hint at real the cause of the error (log mismatch) if you increase verbosity:
The base fail message is however still incorrect. This is made more confusing by the fact that the trace seems to omit logging the parameters (
a
andb
are missing)?Expected Behavior
log != expect ...
message is more specific indicating why the comparison failed:indexed
on some fields)The text was updated successfully, but these errors were encountered: