feat(cheatcodes): disallow usage of expectRevert with expectCall and expectEmit #5144
Merged
Evalir merged 3 commits intoexpect-changesfrom Jun 12, 2023
Merged
feat(cheatcodes): disallow usage of expectRevert with expectCall and expectEmit #5144Evalir merged 3 commits intoexpect-changesfrom
cheatcodes): disallow usage of expectRevert with expectCall and expectEmit #5144Evalir merged 3 commits intoexpect-changesfrom
Conversation
mattsse
approved these changes
Jun 12, 2023
Member
mattsse
left a comment
There was a problem hiding this comment.
This completely disallows matching calls or events if the user has previously used expectRevert
sgtm,
tests look good
| Ok(Bytes::new()) | ||
| } | ||
|
|
||
| fn expect_emit( |
Member
There was a problem hiding this comment.
I like having this as standalone fn
Member
Author
There was a problem hiding this comment.
yeh my objective over time is to make handling cheatcodes a bit more state-machine like, with the ability to compose error messages and add hints and whatnot. This is a small part of it (breaking everything down into functions instead of inlining everything)
Evalir
added a commit
that referenced
this pull request
Jun 26, 2023
* feat(`cheatcodes`): Make expectCall only work for the next call's subcalls (#5032) * chore: make expect call only work for the next call * chore: make expectCall actually check only the next call's subcalls * chore: fmt * chore: introduce checks at the main call level, not at the subcall level * chore: handle dangling expected calls gracefully * chore: fix tests * chore: fmt * chore: forge fmt * chore: actually exclude depth the cheatcode was called from * chore: tests * chore: better docs * chore: comment out impossible to check condition on expectCall * chore: remove unused check * fix(cheatcodes): Correct `expectRevert` behavior (#4945) * chore: add repro test to pass * chore: strictly check for the depth expectRevert was called in, instead of being able to peek at function end * chore: tests * chore: add more repro tests * chore: fmt * chore: clippy * chore: fixup problematic tests, mark them as not working properly * chore: forge fmt * chore: forge fmt * Update evm/src/executor/inspector/cheatcodes/mod.rs * chore: add more info to changelog * chore: fmt * chore(tests): add more cases for `expectEmit` (#5076) * chore(tests): add more extreme cases for expectEmit * chore(tests): add next call fail case for expectEmit * chore(`cheatcodes`): add more edge case tests on `expect*` cheatcodes (#5135) * chore: add edge-cases * chore: add edge case covering #4920 (comment) * feat(`cheatcodes`): disallow usage of `expectRevert` with `expectCall` and `expectEmit` (#5144) * feat(cheatcodes): disallow usage of expectCall/Emit with expectRevert * chore: add tests * chore: fmt * chore: fmt
Evalir
added a commit
that referenced
this pull request
Jul 10, 2023
* feat(`cheatcodes`): `1.0` cheatcode changes (#5045) * feat(`cheatcodes`): Make expectCall only work for the next call's subcalls (#5032) * chore: make expect call only work for the next call * chore: make expectCall actually check only the next call's subcalls * chore: fmt * chore: introduce checks at the main call level, not at the subcall level * chore: handle dangling expected calls gracefully * chore: fix tests * chore: fmt * chore: forge fmt * chore: actually exclude depth the cheatcode was called from * chore: tests * chore: better docs * chore: comment out impossible to check condition on expectCall * chore: remove unused check * fix(cheatcodes): Correct `expectRevert` behavior (#4945) * chore: add repro test to pass * chore: strictly check for the depth expectRevert was called in, instead of being able to peek at function end * chore: tests * chore: add more repro tests * chore: fmt * chore: clippy * chore: fixup problematic tests, mark them as not working properly * chore: forge fmt * chore: forge fmt * Update evm/src/executor/inspector/cheatcodes/mod.rs * chore: add more info to changelog * chore: fmt * chore(tests): add more cases for `expectEmit` (#5076) * chore(tests): add more extreme cases for expectEmit * chore(tests): add next call fail case for expectEmit * chore(`cheatcodes`): add more edge case tests on `expect*` cheatcodes (#5135) * chore: add edge-cases * chore: add edge case covering #4920 (comment) * feat(`cheatcodes`): disallow usage of `expectRevert` with `expectCall` and `expectEmit` (#5144) * feat(cheatcodes): disallow usage of expectCall/Emit with expectRevert * chore: add tests * chore: fmt * chore: fmt * `foundryup`: v1 changes (#5158) * feat(foundryup): look for v1 tag instead of nightly for normal foundryup * feat(foundryup): add ability to download legacy nightly binary with -L flag * feat: use latest release for figuring out the tag name * chore(foundryup): slightly improve stable release detection * chore: use proper repo * make fns async * chore: remove prb math from integration tests * chore: forge fmt * chore: fix some merge leftovers * chore: last test fixes * chore: forge fmt * chore: uncomment etch test * feat(docs): add `RELEASE_PROCESS.md` (#5269) * feat(docs): add RELEASE_PROCESS.md * chore: not include changelog changes in step * chore: bump crates to 1.0.0 (#5346)
Evalir
added a commit
that referenced
this pull request
Jul 10, 2023
* feat(`cheatcodes`): `1.0` cheatcode changes (#5045) * feat(`cheatcodes`): Make expectCall only work for the next call's subcalls (#5032) * chore: make expect call only work for the next call * chore: make expectCall actually check only the next call's subcalls * chore: fmt * chore: introduce checks at the main call level, not at the subcall level * chore: handle dangling expected calls gracefully * chore: fix tests * chore: fmt * chore: forge fmt * chore: actually exclude depth the cheatcode was called from * chore: tests * chore: better docs * chore: comment out impossible to check condition on expectCall * chore: remove unused check * fix(cheatcodes): Correct `expectRevert` behavior (#4945) * chore: add repro test to pass * chore: strictly check for the depth expectRevert was called in, instead of being able to peek at function end * chore: tests * chore: add more repro tests * chore: fmt * chore: clippy * chore: fixup problematic tests, mark them as not working properly * chore: forge fmt * chore: forge fmt * Update evm/src/executor/inspector/cheatcodes/mod.rs * chore: add more info to changelog * chore: fmt * chore(tests): add more cases for `expectEmit` (#5076) * chore(tests): add more extreme cases for expectEmit * chore(tests): add next call fail case for expectEmit * chore(`cheatcodes`): add more edge case tests on `expect*` cheatcodes (#5135) * chore: add edge-cases * chore: add edge case covering #4920 (comment) * feat(`cheatcodes`): disallow usage of `expectRevert` with `expectCall` and `expectEmit` (#5144) * feat(cheatcodes): disallow usage of expectCall/Emit with expectRevert * chore: add tests * chore: fmt * chore: fmt * `foundryup`: v1 changes (#5158) * feat(foundryup): look for v1 tag instead of nightly for normal foundryup * feat(foundryup): add ability to download legacy nightly binary with -L flag * feat: use latest release for figuring out the tag name * chore(foundryup): slightly improve stable release detection * chore: use proper repo * make fns async * chore: remove prb math from integration tests * chore: forge fmt * chore: fix some merge leftovers * chore: last test fixes * chore: forge fmt * chore: uncomment etch test * feat(docs): add `RELEASE_PROCESS.md` (#5269) * feat(docs): add RELEASE_PROCESS.md * chore: not include changelog changes in step * chore: bump crates to 1.0.0 (#5346)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #5138, but will go into the 1.0 branch.
When a function reverts, it's like it never happened as it gets rolled back—but we're still matching calls/events.
Solution
This completely disallows matching calls or events if the user has previously used
expectRevert. This restriction will be in place until theexpectRevertis "filled", meaning until after the next call, by which either the test will fail due to a non-reverting call, or end execution as it effectively reverted.