Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add new expectCall cheatcode variants #4413

Merged
merged 5 commits into from
Feb 24, 2023

Conversation

clabby
Copy link
Contributor

@clabby clabby commented Feb 23, 2023

Overview

Adds two new variants of the expectCall cheatcode that allows for asserting the amount of gas passed to a call.

// Expect a call to an address with the specified msg.value, gas, and calldata.
function expectCall(address, uint256, uint64, bytes calldata) external;

// Expect a call to an address with the specified msg.value and calldata, and a *minimum* amount of gas.
function expectCallMinGas(address, uint256, uint64, bytes calldata) external;

Motivation

Ran into a situation where I need to assert that the amount of gas passed to a nested call is correct in a test.

@clabby clabby marked this pull request as draft February 23, 2023 17:37
@clabby clabby changed the title feat: Add new expectCall cheatcode variant feat: Add new expectCall cheatcode variants Feb 23, 2023
@clabby clabby marked this pull request as ready for review February 23, 2023 18:11
Copy link
Collaborator

@rkrasiuk rkrasiuk left a comment

Choose a reason for hiding this comment

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

lgtm! tests are great as well! comments below are just stylistic suggestions, you can disregard them if not to your liking

evm/src/executor/inspector/cheatcodes/mod.rs Outdated Show resolved Hide resolved
evm/src/executor/inspector/cheatcodes/mod.rs Outdated Show resolved Hide resolved
@rkrasiuk rkrasiuk requested review from gakonst and mattsse February 23, 2023 19:56
@rkrasiuk rkrasiuk added A-cheatcodes Area: cheatcodes T-feature Type: feature labels Feb 23, 2023
@clabby clabby force-pushed the clabby/expect-call-gas branch from 5d1c83a to 6ad536b Compare February 23, 2023 20:15
Copy link
Member

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

LGTM. The real solution I'd love for all these would be a builder pattern abstraction.

evm/src/executor/inspector/cheatcodes/expect.rs Outdated Show resolved Hide resolved
@gakonst gakonst merged commit d0ce3a7 into foundry-rs:master Feb 24, 2023
@clabby clabby deleted the clabby/expect-call-gas branch February 24, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes T-feature Type: feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants