From 810df71b38a25671bdad80161718a6243798a3b4 Mon Sep 17 00:00:00 2001 From: bruno bruno Date: Fri, 7 Jun 2024 10:21:34 +1000 Subject: [PATCH] GMS-1616: Test constructor & deployment in individual test --- test/token/erc1155/ImmutableERC1155.t.sol | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/token/erc1155/ImmutableERC1155.t.sol b/test/token/erc1155/ImmutableERC1155.t.sol index c1624558..5a0410eb 100644 --- a/test/token/erc1155/ImmutableERC1155.t.sol +++ b/test/token/erc1155/ImmutableERC1155.t.sol @@ -120,6 +120,30 @@ contract ImmutableERC1155Test is Test { /* * Contract deployment */ + function test_ValidateDeploymentConstructor() public { + string memory baseURI = "https://base-uri.com"; + string memory contractURI = "https://contract-uri.com"; + uint96 feeNumerator = 500; + address newFeeReceiver = vm.addr(anotherPrivateKey); + + ImmutableERC1155 anotherERC1155 = new ImmutableERC1155( + owner, "new erc1155", "https://base-uri.com", "https://contract-uri.com", address(operatorAllowlist), newFeeReceiver, feeNumerator + ); + + assertEq(anotherERC1155.contractURI(), contractURI); + assertEq(anotherERC1155.baseURI(), baseURI); + + // check owner is admin + bytes32 adminRole = anotherERC1155.DEFAULT_ADMIN_ROLE(); + assertTrue(anotherERC1155.hasRole(adminRole, owner)); + + // check default royalties + (address receiver, uint256 royaltyAmount) = anotherERC1155.royaltyInfo(1, 10000); + assertEq(receiver, newFeeReceiver); + // 500 = 10000 (salePrice) * 500 (feeNumerator) / 10000 (feeDenominator) + assertEq(500, royaltyAmount); + } + function test_DeploymentShouldSetAdminRoleToOwner() public { bytes32 adminRole = immutableERC1155.DEFAULT_ADMIN_ROLE(); assertTrue(immutableERC1155.hasRole(adminRole, owner));