Skip to content

fix(cheatcodes): disallow using vm.prank after vm.startPrank #5520

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

Merged
merged 3 commits into from
Aug 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion evm/src/executor/inspector/cheatcodes/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@ fn prank(
) -> Result {
let prank = Prank::new(prank_caller, prank_origin, new_caller, new_origin, depth, single_call);

if let Some(Prank { used, .. }) = state.prank {
if let Some(Prank { used, single_call, .. }) = state.prank {
ensure!(used, "You cannot overwrite `prank` until it is applied at least once");
// This case can only fail if the user calls `vm.startPrank` and then `vm.prank` later on.
// This should not be possible.
ensure!(single_call == single_call, "You cannot override an ongoing prank with a single vm.prank. Use vm.startPrank to override the current prank.");
}

ensure!(
Expand Down