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(cheatcodes): count assertion for expectEmit #9405

Merged
merged 31 commits into from
Dec 17, 2024
Merged

Conversation

yash-atreya
Copy link
Member

@yash-atreya yash-atreya commented Nov 25, 2024

Motivation

Partially closes #509

Solution

Implement overloads expectEmit and expectRevert with the count arg.

@yash-atreya yash-atreya changed the title Yash/expect count feat(cheatcodes): count for expectEmit and expectRevert Nov 25, 2024
@yash-atreya yash-atreya marked this pull request as draft November 25, 2024 12:50
@yash-atreya yash-atreya self-assigned this Dec 2, 2024
@yash-atreya yash-atreya marked this pull request as ready for review December 2, 2024 13:13
@yash-atreya yash-atreya changed the title feat(cheatcodes): count for expectEmit and expectRevert feat(cheatcodes): count for expectEmit Dec 2, 2024
@yash-atreya yash-atreya changed the title feat(cheatcodes): count for expectEmit feat(cheatcodes): count assertion for expectEmit Dec 2, 2024
crates/cheatcodes/src/test/expect.rs Show resolved Hide resolved
crates/cheatcodes/src/test/expect.rs Show resolved Hide resolved
crates/cheatcodes/src/test/expect.rs Outdated Show resolved Hide resolved
crates/cheatcodes/src/test/expect.rs Outdated Show resolved Hide resolved
crates/cheatcodes/src/test/expect.rs Show resolved Hide resolved
crates/cheatcodes/src/test/expect.rs Outdated Show resolved Hide resolved
crates/cheatcodes/src/inspector.rs Outdated Show resolved Hide resolved
crates/cheatcodes/src/inspector.rs Outdated Show resolved Hide resolved
crates/cheatcodes/src/inspector.rs Outdated Show resolved Hide resolved
@yash-atreya yash-atreya enabled auto-merge (squash) December 12, 2024 14:11
@yash-atreya yash-atreya disabled auto-merge December 12, 2024 14:11
@yash-atreya
Copy link
Member Author

@zerosnacks @grandizzy please drop your final review

Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

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

lgtm!

yash-atreya added a commit to foundry-rs/forge-std that referenced this pull request Dec 17, 2024
Ref: foundry-rs/foundry#9405

Adds the following cheatcodes to the interface:

```solidity
    /// Expect a given number of logs with the provided topics.
    function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external;

    /// Expect a given number of logs from a specific emitter with the provided topics.
    function expectEmit(
        bool checkTopic1,
        bool checkTopic2,
        bool checkTopic3,
        bool checkData,
        address emitter,
        uint64 count
    ) external;

    /// Expect a given number of logs with all topic and data checks enabled.
    function expectEmit(uint64 count) external;

    /// Expect a given number of logs from a specific emitter with all topic and data checks enabled.
    function expectEmit(address emitter, uint64 count) external;
@yash-atreya yash-atreya merged commit 6b07c77 into master Dec 17, 2024
22 checks passed
@yash-atreya yash-atreya deleted the yash/expect-count branch December 17, 2024 15:26
@grandizzy grandizzy added T-feature Type: feature C-forge Command: forge labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge T-feature Type: feature
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

feat(cheatcodes): add negative assertions for expectEmit and expectRevert using count syntax
3 participants