Skip to content

feat(debugger): improve debugger experience when tests fail due to event mismatch #10342

Open
@smol-ninja

Description

@smol-ninja

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.

Image

👾 Link to warp block

Solution 1

Log the first mismatched event parameter in the failure message:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions