forge fundme- lesson14, getting error with prank #1325
Replies: 5 comments 5 replies
-
it is |
Beta Was this translation helpful? Give feedback.
-
// SPDX-License-Identifier: MIT import {Test} from "forge-std/Test.sol"; contract FundmeTest is Test {
} |
Beta Was this translation helpful? Give feedback.
-
still getting the same error |
Beta Was this translation helpful? Give feedback.
-
Uncomment the 'endingFundMeBalance' and then replace the line, assertEq(initialfundmebalance == 0) with assertEq(endingfundmebalance == 0) Let me know, if it works. |
Beta Was this translation helpful? Give feedback.
-
I know this is older but I had the same issue and the problem was using "hoax". Instead use the following:
I understand there is likely a way to use hoax and it be correct, but this is effectively the same as using the hoax included code. It will give you the same outcome. Let me know if this helps and select my comment as the correct answer to your question. All the best. |
Beta Was this translation helpful? Give feedback.
-
function testmultiplefunderswithdraw() public {
uint160 funders = 10;
uint160 index = 2;
for (uint160 i = index; i < funders; i++) {
hoax(address(i), send_value);
fundme.fund{value: send_value};
}
uint256 initialfundmebalance = address(fundme).balance;
uint256 initialownerbalance = fundme.getOwner().balance;
vm.startPrank(fundme.getOwner());
fundme.withdraw();
vm.stopPrank();
error:[FAIL. Reason: cannot overwrite a prank until it is applied at least once] testmultiplefunderswithdraw() (gas: 4439)
Beta Was this translation helpful? Give feedback.
All reactions