From 32d1524bd8680acf21b8652e4a74b53ca258a203 Mon Sep 17 00:00:00 2001 From: Sebastian Liu Date: Mon, 2 Sep 2024 12:37:56 -0700 Subject: [PATCH] fix(test): modify tests to work w/ the latest protocol --- contracts/SPGNFT.sol | 5 +---- contracts/lib/Errors.sol | 2 +- test/SPGNFT.t.sol | 1 - test/StoryProtocolGateway.t.sol | 15 ++++++++++----- test/utils/BaseTest.t.sol | 11 +++-------- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/contracts/SPGNFT.sol b/contracts/SPGNFT.sol index 36581e9..d419e7f 100644 --- a/contracts/SPGNFT.sol +++ b/contracts/SPGNFT.sol @@ -174,10 +174,7 @@ contract SPGNFT is ISPGNFT, ERC721URIStorageUpgradeable, AccessControlUpgradeabl /// @param to The address of the recipient of the minted NFT. /// @param nftMetadataURI OPTIONAL. The URI of the desired metadata for the newly minted NFT. /// @return tokenId The ID of the minted NFT. - function mint( - address to, - string calldata nftMetadataURI - ) public virtual returns (uint256 tokenId) { + function mint(address to, string calldata nftMetadataURI) public virtual returns (uint256 tokenId) { if (!_getSPGNFTStorage().publicMinting && !hasRole(SPGNFTLib.MINTER_ROLE, msg.sender)) { revert Errors.SPGNFT__MintingDenied(); } diff --git a/contracts/lib/Errors.sol b/contracts/lib/Errors.sol index a0f3f02..5c58163 100644 --- a/contracts/lib/Errors.sol +++ b/contracts/lib/Errors.sol @@ -33,7 +33,7 @@ library Errors { /// @notice Minting is closed. error SPGNFT__MintingClosed(); - + /// @notice Caller is not one of the periphery contracts. error SPGNFT__CallerNotPeripheryContract(); diff --git a/test/SPGNFT.t.sol b/test/SPGNFT.t.sol index 1677aec..987e2fe 100644 --- a/test/SPGNFT.t.sol +++ b/test/SPGNFT.t.sol @@ -14,7 +14,6 @@ import { Errors } from "../contracts/lib/Errors.sol"; import { BaseTest } from "./utils/BaseTest.t.sol"; contract SPGNFTTest is BaseTest { - address internal feeRecipient; string internal nftMetadataEmpty; string internal nftMetadataDefault; diff --git a/test/StoryProtocolGateway.t.sol b/test/StoryProtocolGateway.t.sol index 6bde58c..14630f6 100644 --- a/test/StoryProtocolGateway.t.sol +++ b/test/StoryProtocolGateway.t.sol @@ -21,8 +21,6 @@ contract StoryProtocolGatewayTest is BaseTest { address owner; } - address internal feeRecipient; - mapping(uint256 index => IPAsset) internal ipAsset; address internal ipIdParent; @@ -433,14 +431,17 @@ contract StoryProtocolGatewayTest is BaseTest { nftContracts = new ISPGNFT[](10); bytes[] memory data = new bytes[](10); for (uint256 i = 0; i < 10; i++) { - data[i] = abi.encodeWithSignature( - "createCollection(string,string,uint32,uint256,address,address)", + data[i] = abi.encodeWithSelector( + spg.createCollection.selector, "Test Collection", "TEST", 100, 100 * 10 ** mockToken.decimals(), address(mockToken), - minter + feeRecipient, + minter, + true, + false ); } @@ -455,6 +456,10 @@ contract StoryProtocolGatewayTest is BaseTest { assertEq(nftContracts[i].totalSupply(), 0); assertTrue(nftContracts[i].hasRole(SPGNFTLib.MINTER_ROLE, alice)); assertEq(nftContracts[i].mintFee(), 100 * 10 ** mockToken.decimals()); + assertEq(nftContracts[i].mintFeeToken(), address(mockToken)); + assertEq(nftContracts[i].mintFeeRecipient(), bob); + assertTrue(nftContracts[i].mintOpen()); + assertFalse(nftContracts[i].publicMinting()); } } diff --git a/test/utils/BaseTest.t.sol b/test/utils/BaseTest.t.sol index b4effe3..f38e51d 100644 --- a/test/utils/BaseTest.t.sol +++ b/test/utils/BaseTest.t.sol @@ -198,7 +198,7 @@ contract BaseTest is Test { impl = address(0); // Make sure we don't deploy wrong impl address ipAccountRegistry = address(ipAssetRegistry); - impl = address(new AccessController()); + impl = address(new AccessController(address(ipAssetRegistry), address(moduleRegistry))); accessController = AccessController( TestProxyHelper.deployUUPSProxy( create3Deployer, @@ -278,6 +278,7 @@ contract BaseTest is Test { impl = address(0); // Make sure we don't deploy wrong impl impl = address( new RoyaltyModule( + _getDeployedAddress(type(LicensingModule).name), address(disputeModule), address(licenseRegistry), address(ipAssetRegistry) @@ -302,6 +303,7 @@ contract BaseTest is Test { new LicensingModule( address(accessController), address(ipAccountRegistry), + address(moduleRegistry), address(royaltyModule), address(licenseRegistry), address(disputeModule), @@ -480,13 +482,6 @@ contract BaseTest is Test { moduleRegistry.registerModule("CORE_METADATA_VIEW_MODULE", address(coreMetadataViewModule)); moduleRegistry.registerModule("GROUPING_MODULE", address(groupingModule)); - accessController.setAddresses(address(ipAssetRegistry), address(moduleRegistry)); - licenseRegistry.setDisputeModule(address(disputeModule)); - licenseRegistry.setLicensingModule(address(licensingModule)); - licenseToken.setLicensingModule(address(licensingModule)); - licenseToken.setDisputeModule(address(disputeModule)); - royaltyModule.setLicensingModule(address(licensingModule)); - coreMetadataViewModule.updateCoreMetadataModule(); licenseRegistry.registerLicenseTemplate(address(pilTemplate));