|
| 1 | +// SPDX-License-Identifier: Apache-2.0 |
| 2 | +pragma solidity ^0.8.0; |
| 3 | + |
| 4 | +import { OpenEditionERC721 } from "contracts/prebuilts/open-edition/OpenEditionERC721.sol"; |
| 5 | +import { TWProxy } from "contracts/infra/TWProxy.sol"; |
| 6 | + |
| 7 | +// Test imports |
| 8 | +import "src/test/utils/BaseTest.sol"; |
| 9 | + |
| 10 | +contract OpenEditionERC721Harness is OpenEditionERC721 { |
| 11 | + function canSetPrimarySaleRecipient() external view returns (bool) { |
| 12 | + return _canSetPrimarySaleRecipient(); |
| 13 | + } |
| 14 | + |
| 15 | + function canSetOwner() external view returns (bool) { |
| 16 | + return _canSetOwner(); |
| 17 | + } |
| 18 | + |
| 19 | + /// @dev Checks whether royalty info can be set in the given execution context. |
| 20 | + function canSetRoyaltyInfo() external view returns (bool) { |
| 21 | + return _canSetRoyaltyInfo(); |
| 22 | + } |
| 23 | + |
| 24 | + /// @dev Checks whether contract metadata can be set in the given execution context. |
| 25 | + function canSetContractURI() external view returns (bool) { |
| 26 | + return _canSetContractURI(); |
| 27 | + } |
| 28 | + |
| 29 | + /// @dev Checks whether platform fee info can be set in the given execution context. |
| 30 | + function canSetClaimConditions() external view returns (bool) { |
| 31 | + return _canSetClaimConditions(); |
| 32 | + } |
| 33 | + |
| 34 | + /// @dev Returns whether the shared metadata of tokens can be set in the given execution context. |
| 35 | + function canSetSharedMetadata() external view virtual returns (bool) { |
| 36 | + return _canSetSharedMetadata(); |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +contract OpenEditionERC721Test_canSetFunctions is BaseTest { |
| 41 | + OpenEditionERC721Harness public openEdition; |
| 42 | + |
| 43 | + address private openEditionImpl; |
| 44 | + |
| 45 | + function setUp() public override { |
| 46 | + super.setUp(); |
| 47 | + openEditionImpl = address(new OpenEditionERC721Harness()); |
| 48 | + vm.prank(deployer); |
| 49 | + openEdition = OpenEditionERC721Harness( |
| 50 | + address( |
| 51 | + new TWProxy( |
| 52 | + openEditionImpl, |
| 53 | + abi.encodeCall( |
| 54 | + OpenEditionERC721.initialize, |
| 55 | + ( |
| 56 | + deployer, |
| 57 | + NAME, |
| 58 | + SYMBOL, |
| 59 | + CONTRACT_URI, |
| 60 | + forwarders(), |
| 61 | + saleRecipient, |
| 62 | + royaltyRecipient, |
| 63 | + royaltyBps |
| 64 | + ) |
| 65 | + ) |
| 66 | + ) |
| 67 | + ) |
| 68 | + ); |
| 69 | + } |
| 70 | + |
| 71 | + /*/////////////////////////////////////////////////////////////// |
| 72 | + Unit tests: misc |
| 73 | + //////////////////////////////////////////////////////////////*/ |
| 74 | + |
| 75 | + function test_canSetPrimarySaleRecipient_returnTrue() public { |
| 76 | + vm.prank(deployer); |
| 77 | + assertTrue(openEdition.canSetPrimarySaleRecipient()); |
| 78 | + } |
| 79 | + |
| 80 | + function test_canSetPrimarySaleRecipient_returnFalse() public { |
| 81 | + assertFalse(openEdition.canSetPrimarySaleRecipient()); |
| 82 | + } |
| 83 | + |
| 84 | + function test_canSetOwner_returnTrue() public { |
| 85 | + vm.prank(deployer); |
| 86 | + assertTrue(openEdition.canSetOwner()); |
| 87 | + } |
| 88 | + |
| 89 | + function test_canSetOwner_returnFalse() public { |
| 90 | + assertFalse(openEdition.canSetOwner()); |
| 91 | + } |
| 92 | + |
| 93 | + function test_canSetRoyaltyInfo_returnTrue() public { |
| 94 | + vm.prank(deployer); |
| 95 | + assertTrue(openEdition.canSetRoyaltyInfo()); |
| 96 | + } |
| 97 | + |
| 98 | + function test_canSetRoyaltyInfo_returnFalse() public { |
| 99 | + assertFalse(openEdition.canSetRoyaltyInfo()); |
| 100 | + } |
| 101 | + |
| 102 | + function test_canSetContractURI_returnTrue() public { |
| 103 | + vm.prank(deployer); |
| 104 | + assertTrue(openEdition.canSetContractURI()); |
| 105 | + } |
| 106 | + |
| 107 | + function test_canSetContractURI_returnFalse() public { |
| 108 | + assertFalse(openEdition.canSetContractURI()); |
| 109 | + } |
| 110 | + |
| 111 | + function test_canSetClaimConditions_returnTrue() public { |
| 112 | + vm.prank(deployer); |
| 113 | + assertTrue(openEdition.canSetClaimConditions()); |
| 114 | + } |
| 115 | + |
| 116 | + function test_canSetClaimConditions_returnFalse() public { |
| 117 | + assertFalse(openEdition.canSetClaimConditions()); |
| 118 | + } |
| 119 | + |
| 120 | + function test_canSetSharedMetadata_returnTrue() public { |
| 121 | + vm.prank(deployer); |
| 122 | + assertTrue(openEdition.canSetSharedMetadata()); |
| 123 | + } |
| 124 | + |
| 125 | + function test_canSetSharedMetadata_returnFalse() public { |
| 126 | + assertFalse(openEdition.canSetSharedMetadata()); |
| 127 | + } |
| 128 | +} |
0 commit comments