Skip to content

feat(cheatcodes): add vm.expectMockCall to enforce that a mocked function is called with certain arguments #5480

@JasoonS

Description

@JasoonS

Component

Forge

Describe the feature you would like

Currently tests don't break if a mocked function is called with different arguments to what was expected.

Currently for example:

    cheats.mockCall(
      address(mocker),
      abi.encodeWithSelector(
        SomeContract.someFunction.selector,
        5
      ),
      abi.encode(6)
    );

With the above code it will return 6 if the function is called with an argument of 5 or anything else, additionally it won't fail if it isn't called with 5 (which is something you sometimes want to check.

I propose adding a function called something like mockCallStrict to the cheats so that tests can be more strict about this.

Additional context

This is a feature of Smock: https://smock.readthedocs.io/en/latest/fakes.html#asserting-call-arguments

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Next Up

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions