Skip to content

Commit

Permalink
Fix, add EOA prank test
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy committed Nov 15, 2024
1 parent 7d76b70 commit 80217b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/cheatcodes/src/evm/prank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,28 @@ impl Cheatcode for startPrank_1Call {
}

impl Cheatcode for prank_2Call {
fn apply_stateful<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender, delegateCall } = self;
prank(ccx, msgSender, None, true, *delegateCall)
}
}

impl Cheatcode for startPrank_2Call {
fn apply_stateful<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender, delegateCall } = self;
prank(ccx, msgSender, None, false, *delegateCall)
}
}

impl Cheatcode for prank_3Call {
fn apply_stateful<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender, txOrigin, delegateCall } = self;
prank(ccx, msgSender, Some(txOrigin), true, *delegateCall)
}
}

impl Cheatcode for startPrank_3Call {
fn apply_stateful<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender, txOrigin, delegateCall } = self;
prank(ccx, msgSender, Some(txOrigin), false, *delegateCall)
}
Expand Down
8 changes: 8 additions & 0 deletions testdata/default/cheats/Prank.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ contract PrankTest is DSTest {
vm.stopPrank();
}

function testFailPrankDelegateCallToEOA() public {
address alice = makeAddr("alice");
ImplementationTest impl = new ImplementationTest();
vm.prank(alice, true);
// Should fail when EOA pranked with delegatecall.
address(impl).delegatecall(abi.encodeWithSignature("assertCorrectCaller(address)", alice));
}

function testPrankSender(address sender) public {
// Perform the prank
Victim victim = new Victim();
Expand Down

0 comments on commit 80217b1

Please sign in to comment.