Skip to content

Instantly share code, notes, and snippets.

@wilsoncusack
Created December 21, 2021 12:19
Show Gist options
  • Save wilsoncusack/6562a2f974607a6ad8f267f0921997c9 to your computer and use it in GitHub Desktop.
Save wilsoncusack/6562a2f974607a6ad8f267f0921997c9 to your computer and use it in GitHub Desktop.
Prank Payable
interface Vm {
function prank(address) external;
}
contract Foo {
function bar() public {
require(msg.sender == address(1), 'wrong sender');
}
function barPayable() public payable {
require(msg.sender == address(1), 'wrong sender');
}
}
contract MyTest is DSTest {
Vm vm = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
Foo foo;
function setUp() public {
foo = new Foo();
}
function testBar() public {
address new_sender = address(1);
vm.prank(new_sender);
foo.bar();
}
function testBarPayable() public {
address new_sender = address(1);
vm.prank(new_sender);
foo.barPayable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment