Skip to content

bug(cheatcodes): vm.expertRevert(bytes) reports misleading failure diagnostic #10162

Open
@norswap

Description

@norswap

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge Version: 1.0.0-stable Commit SHA: e144b82 Build Timestamp: 2025-02-13T20:02:34.979686000Z (1739476954) Build Profile: maxperf

What version of Foundryup are you on?

foundryup: 1.0.1

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

If I ran the following snippet in my tests:

vm.expectRevert(abi.encodeWithSelector(ValidationFailed.selector, InvalidNonce.selector));
happyEntryPoint.submit(encodedHappyTx);

I receive the following test failure:

[FAIL: Error != expected error: ValidationFailed(0x756688fe) != ValidationFailed(0x)]

The mistake was that it should have been:

vm.expectRevert(abi.encodeWithSelector(ValidationFailed.selector, abi.encodeWithSelector(InvalidNonce.selector)));

But the ValidationFailed(0x) really threw me for a loop. I guess forge wasn't able to ABI parse the incorrect revertData, leading to display Validation(0x) instead, a half-parsed version.

I would suggest it's more useful to display the entire revertData in this case, if it can't be parsed in its entirety — as foundry already does in some other places (I think when it can't identify the initial selector). Alternatively ValidationFailed(<failed to parse>) would be useful as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions