Created
December 21, 2021 12:19
-
-
Save wilsoncusack/6562a2f974607a6ad8f267f0921997c9 to your computer and use it in GitHub Desktop.
Prank Payable
This file contains 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
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