stdError.arithmeticError
Original Implementation
function withdraw(uint amount) external {
require(balances[msg.sender] >= amount, "Insufficient balance!");
emit Withdrawal(msg.sender, amount);
balances[msg.sender] -= amount;
(bool success) = wmdToken.transfer(address(this), amount);
require(success, "Token transfer frm User to Vendor failed!");
} function testUserCannotWithdraw(uint amount) public {
console2.log("User cannot withdraw with no balance");
vm.assume(amount > 0);
vm.prank(user);
vm.expectRevert("Insufficient balance!");
vault.withdraw(amount);
}Alberto said:
Richie elaborated:
Correct Implementation
The takeaway here is that:
Last updated