// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {Test} from "forge-std/Test.sol"; import {SafeERC721Drop} from "../src/SafeERC721Drop.sol"; contract SafeERC721DropTest is Test { SafeERC721Drop drop; address owner = makeAddr("owner"); address treasury = makeAddr("treasury"); address alice = makeAddr("alice"); function setUp() public { drop = new SafeERC721Drop("Safe", "SAFE", 3, treasury, 1 ether, 2, owner); vm.deal(alice, 10 ether); } function testMintPaymentAndWalletCap() public { vm.prank(alice); drop.mint{value: 2 ether}(2); assertEq(drop.balanceOf(alice), 2); vm.prank(alice); vm.expectRevert("wallet cap"); drop.mint{value: 1 ether}(1); } function testRejectsWrongPayment() public { vm.prank(alice); vm.expectRevert("wrong payment"); drop.mint{value: 0.5 ether}(1); } function testCollectionCap() public { address bob = makeAddr("bob"); vm.deal(bob, 2 ether); vm.prank(alice); drop.mint{value: 2 ether}(2); vm.prank(bob); drop.mint{value: 1 ether}(1); address carol = makeAddr("carol"); vm.deal(carol, 1 ether); vm.prank(carol); vm.expectRevert("collection cap"); drop.mint{value: 1 ether}(1); } function testOnlyOwnerWithdrawsToTreasury() public { vm.prank(alice); drop.mint{value: 1 ether}(1); vm.prank(alice); vm.expectRevert(); drop.withdraw(); uint256 beforeBalance = treasury.balance; vm.prank(owner); drop.withdraw(); assertEq(treasury.balance, beforeBalance + 1 ether); assertEq(address(drop).balance, 0); } }