Skip to content

Commit

Permalink
add a withdraw test for insufficient approval
Browse files Browse the repository at this point in the history
  • Loading branch information
omnifient committed Aug 2, 2023
1 parent b1f6dcd commit 1a599cb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/WithdrawUnlock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,23 @@ contract WithdrawUnlock is Base {
vm.expectRevert();
_minterBurner.withdraw(_alice, 0);
}

/// @notice Alice approves spending 500 L2_USDC and tries to withdraw 1000 L2_USDC.
function testRevertWhenInsufficientApproval() public {
// setup the withdrawal
vm.selectFork(_l2Fork);
uint256 balance1 = _erc20L2Usdc.balanceOf(_alice);

uint256 approvalAmount = _toUSDC(500);
uint256 withdrawAmount = _toUSDC(1000);
_erc20L2Usdc.approve(address(_minterBurner), approvalAmount);

// try to withdraw the L2_USDC
vm.expectRevert();
_minterBurner.withdraw(_alice, withdrawAmount);

// alice's L2_USDC balance is the same
uint256 balance2 = _erc20L2Usdc.balanceOf(_alice);
assertEq(balance1, balance2);
}
}

0 comments on commit 1a599cb

Please sign in to comment.