|
| 1 | +// SPDX-License-Identifier: Apache-2.0 |
| 2 | +pragma solidity ^0.8.0; |
| 3 | + |
| 4 | +import { DropERC721 } from "contracts/prebuilts/drop/DropERC721.sol"; |
| 5 | + |
| 6 | +// Test imports |
| 7 | +import "../../../utils/BaseTest.sol"; |
| 8 | + |
| 9 | +contract DropERC721Test_canSetFunctions is BaseTest { |
| 10 | + DropERC721 public drop; |
| 11 | + |
| 12 | + bytes private canset_data; |
| 13 | + string private canset_baseURI; |
| 14 | + uint256 private canset_amount; |
| 15 | + bytes private canset_encryptedURI; |
| 16 | + bytes32 private canset_provenanceHash; |
| 17 | + address private unauthorized = address(0x123); |
| 18 | + |
| 19 | + function setUp() public override { |
| 20 | + super.setUp(); |
| 21 | + drop = DropERC721(getContract("DropERC721")); |
| 22 | + } |
| 23 | + |
| 24 | + /*/////////////////////////////////////////////////////////////// |
| 25 | + Branch Testing |
| 26 | + //////////////////////////////////////////////////////////////*/ |
| 27 | + |
| 28 | + modifier callerNotAdmin() { |
| 29 | + vm.startPrank(unauthorized); |
| 30 | + _; |
| 31 | + } |
| 32 | + |
| 33 | + modifier callerAdmin() { |
| 34 | + vm.startPrank(deployer); |
| 35 | + _; |
| 36 | + } |
| 37 | + |
| 38 | + modifier callerNotMinter() { |
| 39 | + vm.startPrank(unauthorized); |
| 40 | + _; |
| 41 | + } |
| 42 | + |
| 43 | + modifier callerMinter() { |
| 44 | + vm.startPrank(deployer); |
| 45 | + _; |
| 46 | + } |
| 47 | + |
| 48 | + function test__canSetPlatformFeeInfo_revert_callerNotAdmin() public callerNotAdmin { |
| 49 | + vm.expectRevert("Not authorized"); |
| 50 | + drop.setPlatformFeeInfo(address(0x1), 1); |
| 51 | + } |
| 52 | + |
| 53 | + function test__canSetPlatformFeeInfo_callerAdmin() public callerAdmin { |
| 54 | + drop.setPlatformFeeInfo(address(0x1), 1); |
| 55 | + (address recipient, uint16 bps) = drop.getPlatformFeeInfo(); |
| 56 | + assertEq(recipient, address(0x1)); |
| 57 | + assertEq(bps, 1); |
| 58 | + } |
| 59 | + |
| 60 | + function test__canSetPrimarySaleRecipient_revert_callerNotAdmin() public callerNotAdmin { |
| 61 | + vm.expectRevert("Not authorized"); |
| 62 | + drop.setPrimarySaleRecipient(address(0x1)); |
| 63 | + } |
| 64 | + |
| 65 | + function test__canSetPrimarySaleRecipient_callerAdmin() public callerAdmin { |
| 66 | + drop.setPrimarySaleRecipient(address(0x1)); |
| 67 | + assertEq(drop.primarySaleRecipient(), address(0x1)); |
| 68 | + } |
| 69 | + |
| 70 | + function test__canSetOwner_revert_callerNotAdmin() public callerNotAdmin { |
| 71 | + vm.expectRevert("Not authorized"); |
| 72 | + drop.setOwner(address(0x1)); |
| 73 | + } |
| 74 | + |
| 75 | + function test__canSetOwner_callerAdmin() public callerAdmin { |
| 76 | + drop.setOwner(address(0x1)); |
| 77 | + assertEq(drop.owner(), address(0x1)); |
| 78 | + } |
| 79 | + |
| 80 | + function test__canSetRoyaltyInfo_revert_callerNotAdmin() public callerNotAdmin { |
| 81 | + vm.expectRevert("Not authorized"); |
| 82 | + drop.setDefaultRoyaltyInfo(address(0x1), 1); |
| 83 | + } |
| 84 | + |
| 85 | + function test__canSetRoyaltyInfo_callerAdmin() public callerAdmin { |
| 86 | + drop.setDefaultRoyaltyInfo(address(0x1), 1); |
| 87 | + (address recipient, uint16 bps) = drop.getDefaultRoyaltyInfo(); |
| 88 | + assertEq(recipient, address(0x1)); |
| 89 | + assertEq(bps, 1); |
| 90 | + } |
| 91 | + |
| 92 | + function test__canSetContractURI_revert_callerNotAdmin() public callerNotAdmin { |
| 93 | + vm.expectRevert("Not authorized"); |
| 94 | + drop.setContractURI("ipfs://"); |
| 95 | + } |
| 96 | + |
| 97 | + function test__canSetContractURI_callerAdmin() public callerAdmin { |
| 98 | + drop.setContractURI("ipfs://"); |
| 99 | + assertEq(drop.contractURI(), "ipfs://"); |
| 100 | + } |
| 101 | + |
| 102 | + function test__canSetClaimConditions_revert_callerNotAdmin() public callerNotAdmin { |
| 103 | + DropERC721.ClaimCondition[] memory conditions = new DropERC721.ClaimCondition[](1); |
| 104 | + conditions[0].maxClaimableSupply = 500; |
| 105 | + conditions[0].quantityLimitPerWallet = 10; |
| 106 | + conditions[0].merkleRoot = bytes32(0); |
| 107 | + conditions[0].pricePerToken = 10; |
| 108 | + conditions[0].currency = address(0x111); |
| 109 | + vm.expectRevert("Not authorized"); |
| 110 | + drop.setClaimConditions(conditions, true); |
| 111 | + } |
| 112 | + |
| 113 | + function test__canSetClaimConditions_callerAdmin() public callerAdmin { |
| 114 | + DropERC721.ClaimCondition[] memory conditions = new DropERC721.ClaimCondition[](1); |
| 115 | + conditions[0].maxClaimableSupply = 500; |
| 116 | + conditions[0].quantityLimitPerWallet = 10; |
| 117 | + conditions[0].merkleRoot = bytes32(0); |
| 118 | + conditions[0].pricePerToken = 10; |
| 119 | + conditions[0].currency = address(0x111); |
| 120 | + drop.setClaimConditions(conditions, true); |
| 121 | + } |
| 122 | + |
| 123 | + function test__canLazyMint_revert_callerNotMinter() public callerNotMinter { |
| 124 | + canset_amount = 10; |
| 125 | + canset_baseURI = "ipfs://"; |
| 126 | + canset_data = abi.encode(canset_encryptedURI, canset_provenanceHash); |
| 127 | + vm.expectRevert("Not authorized"); |
| 128 | + drop.lazyMint(canset_amount, canset_baseURI, canset_data); |
| 129 | + } |
| 130 | + |
| 131 | + function test__canLazyMint_callerMinter() public callerMinter { |
| 132 | + canset_amount = 10; |
| 133 | + canset_baseURI = "ipfs://"; |
| 134 | + canset_data = abi.encode(canset_encryptedURI, canset_provenanceHash); |
| 135 | + drop.lazyMint(canset_amount, canset_baseURI, canset_data); |
| 136 | + } |
| 137 | +} |
0 commit comments