Skip to content

feat(forge): overload expectCall and mockCall with msg.value#1619

Merged
onbjerg merged 6 commits intofoundry-rs:masterfrom
AdithyaNarayan:cheatcodes-msg-value
May 16, 2022
Merged

feat(forge): overload expectCall and mockCall with msg.value#1619
onbjerg merged 6 commits intofoundry-rs:masterfrom
AdithyaNarayan:cheatcodes-msg-value

Conversation

@AdithyaNarayan
Copy link
Copy Markdown
Contributor

Closes #1568
Closes #1604

  • Added overloaded expectCall with msg.value
  • Added overloaded mockCall with `msg.value
  • Fixed mockCall partial calldata matching

Solution

Implementation for the overloading of expectCall was straightforward with a new struct that contains the calldata and msg.value.

For the mockCall, Ord trait was implemented for MockCallDataContext to ensure that partial matching is consistent.
The partial match now allows for the longest prefix in the calldata to be matched if there is no exact match.

There is also a new precedence order, and a more specific calldata precedes a msg.value match with a shorter prefix calldata match.

Copy link
Copy Markdown
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit

@onbjerg onbjerg added the T-feature Type: feature label May 15, 2022
@AdithyaNarayan
Copy link
Copy Markdown
Contributor Author

Should I also do a PR to forge-std to add the new calls to Vm.sol?

@onbjerg
Copy link
Copy Markdown
Member

onbjerg commented May 16, 2022

Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-feature Type: feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mockCall's calldata partial matching behaviour doesn't work as expected expectCall cheatcode overloaded with msg.value assertion

2 participants