foundry-rs / foundry-rs/foundry
feat(`debugger`): improve debugger experience when tests fail due to event mismatch
- Dominant language
- Rust
- Stars
- 10.6k
- Forks
- 2.6k
- Avg merge
- 16h 38m
- Merged PRs (30d)
- 511
Description
### Component
Forge, Foundryup
### Describe the feature you would like
### Problem
When a test fails due to event mismatch, Foundry logs `FAIL: log != expected log; counterexample calldata=0x1234....1234` without specifying which event parameter did not match.
Though this is fine for simple tests, in case of fuzz testing, it becomes very problematic. This is because Foundry prints lengthy `calldata` forcing to scroll extensively to trace down the error.

👾 [Link to warp block](https://app.warp.dev/block/LO8P0XzdGwbeHxToZdRhp7)
### Solution 1
Log the first mismatched event parameter in the failure message:
```bash
FAIL: log != expected log event_name:event_parameter expectedValue != actualValue; counterexample calldata=0x1234..1234
```
This would make it easier to identify which event parameter did not match with the expected value without having to scroll down so much.
### Solution 2
Add a Foundry cheat code to enable/disable `calldata` logs. It can be called `display_calldata`
Most of the times, having `calldata` printed is of little value. This is because, use of `bound` can change the value of the input parameters. Thus, having a cheatcode to enable `calldata` logging can be more useful than having it enabled by default.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.