Skip to content

vm.prank( ) cannot understand . #164

Closed Answered by pacelliv
Debangshu97 asked this question in Q&A
Discussion options

You must be logged in to vote

Before speaking about prank, let me explain a little bit about what I've learned about Foundry.

In foundry everything is a conctract -- scripts, tests, libraries, imports, etc..., due to this reason Foundry has set up a serie of default addresses that acts as the msg.sender to execute these files and the functions in them.

When we execute a test, is not our private key that is being used, in fact is a key from Foundry.

function testConsoleCaller() public view {
    console.log(msg.sender); // is not you!
}

This behaviour could be problematic depending on the test, for example the withdraw function from the FundMe contract has a modifier that only allows the owner to withdraw the funds, bu…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@cromewar
Comment options

Answer selected by cromewar
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants