Skip to content

i want to ask this unit test about "fundme":why does the last assert add 1? #3320

Answered by KMean
lc345 asked this question in Q&A
Discussion options

You must be logged in to vote

@lc345 because we are using the funded modifier which prank the USER and send some funds to the contract

 modifier funded() {
        vm.prank(USER);
        fundMe.fund{value: SEND_VALUE}();
        assert(address(fundMe).balance > 0);
        _;
    }

so we need to count for that in the assertion. In fact if you log the amount of USER contribution you will see it does indeed exist.

function testWithdrawFromMultipleFunders() public funded skipZkSync {
        uint160 numberOfFunders = 10;
        uint160 startingFunderIndex = 2;
        console.log("USER contribution:", fundMe.getAddressToAmountFunded(USER));
        for (uint160 i = startingFunderIndex; i < numberOfFunders + startingFun…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by lc345
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants