Skip to content

Commit ca67d15

Browse files
Evalirmds1
andauthored
fix(cheatcodes): disallow using vm.prank after vm.startPrank (#5520)
* chore: disallow using vm.prank after vm.startprank * chore: rename state single call bool * Update evm/src/executor/inspector/cheatcodes/env.rs Co-authored-by: Matt Solomon <[email protected]> --------- Co-authored-by: Matt Solomon <[email protected]>
1 parent cf03bb6 commit ca67d15

File tree

1 file changed

+4
-1
lines changed
  • evm/src/executor/inspector/cheatcodes

1 file changed

+4
-1
lines changed

evm/src/executor/inspector/cheatcodes/env.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ fn prank(
161161
) -> Result {
162162
let prank = Prank::new(prank_caller, prank_origin, new_caller, new_origin, depth, single_call);
163163

164-
if let Some(Prank { used, .. }) = state.prank {
164+
if let Some(Prank { used, single_call: current_single_call, .. }) = state.prank {
165165
ensure!(used, "You cannot overwrite `prank` until it is applied at least once");
166+
// This case can only fail if the user calls `vm.startPrank` and then `vm.prank` later on.
167+
// This should not be possible without first calling `stopPrank`
168+
ensure!(single_call == current_single_call, "You cannot override an ongoing prank with a single vm.prank. Use vm.startPrank to override the current prank.");
166169
}
167170

168171
ensure!(

0 commit comments

Comments
 (0)