test fails on testnet if wallet balance is not zero
0xpantera opened this issue · comments
Franco commented
The test testPerformUpkeepRevertsIfCheckUpkeepIsFalse
which does not have the skipFork
modifier will fail if the wallet balance on Sepolia is not zero.
function testPerformUpkeepRevertsIfCheckUpkeepIsFalse() public {
uint256 currentBalance = 0;
uint256 numPlayers = 0;
uint256 raffleState = 0;
vm.expectRevert(
abi.encodeWithSelector(
Raffle.Raffle__UpkeepNotNeeded.selector,
currentBalance,
numPlayers,
raffleState
)
);
raffle.performUpkeep("");
}
If wallet balance on Sepolia is not zero test will fail because it will throw a different error than the expected one by vm.expectRevert()
:
Expected error:
VM::expectRevert(Raffle__UpkeepNotNeeded(0, 0, 0))
Actual error:
VM::expectRevert(Raffle__UpkeepNotNeeded(actual-wallet-balance, 0, 0))
Test fail reason:
[FAIL. Reason: Error != expected error: 0x584327aa00000000000000000000000000000000000000000000000004f3c18bfe17f90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 != ]
Patrick Collins commented
Ah! So we should add this modifier. Good shout, any chance you'd be interested in making the PR?
Franco commented
Sorry, just saw this. I'd be happy to make the PR if it hasn't already been made.
Patrick Collins commented
Ah, I think this test is still correct.
revert Raffle__UpkeepNotNeeded(
address(this).balance,
s_players.length,
uint256(s_raffleState)
);
address(this).balance
is referring to the balance of the contract, not the wallet.