diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index bef19c982..18da216af 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: true - name: Foundry project + name: Check solidity test coverage runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -42,6 +42,7 @@ jobs: uses: zgosalvez/github-actions-report-lcov@v2 with: coverage-files: lcov.info + minimum-coverage: 89 artifact-name: code-coverage-report github-token: ${{ secrets.GITHUB_TOKEN }} working-directory: ./ diff --git a/test/factory/ZoraCreator1155Factory_Fork.t.sol b/test/factory/ZoraCreator1155Factory_Fork.t.sol index 3abe1eaa9..894b55c6d 100644 --- a/test/factory/ZoraCreator1155Factory_Fork.t.sol +++ b/test/factory/ZoraCreator1155Factory_Fork.t.sol @@ -36,40 +36,43 @@ contract ZoraCreator1155FactoryForkTest is ForkDeploymentConfig, Test { } } - function testTheFork(string memory chainName) private { - console.log("testing on fork: ", chainName); + function _setupToken(IZoraCreator1155 target, IMinter1155 fixedPrice, uint96 tokenPrice) private returns (uint256 tokenId) { + string memory tokenURI = "ipfs://token"; + uint256 tokenMaxSupply = 100; - // create and select the fork, which will be used for all subsequent calls - // it will also affect the current block chain id based on the rpc url returned - vm.createSelectFork(vm.rpcUrl(chainName)); + tokenId = target.setupNewToken(tokenURI, tokenMaxSupply); - address factoryAddress = getDeployment().factoryProxy; - IZoraCreator1155Factory factory = IZoraCreator1155Factory(factoryAddress); + target.addPermission(tokenId, address(fixedPrice), PERMISSION_BIT_MINTER); - assertEq(getChainConfig().factoryOwner, IOwnable(factoryAddress).owner(), string.concat("configured owner incorrect on: ", chainName)); + target.callSale( + tokenId, + fixedPrice, + abi.encodeWithSelector( + ZoraCreatorFixedPriceSaleStrategy.setSale.selector, + tokenId, + ZoraCreatorFixedPriceSaleStrategy.SalesConfig({ + pricePerToken: tokenPrice, + saleStart: 0, + saleEnd: type(uint64).max, + maxTokensPerAddress: 0, + fundsRecipient: address(0) + }) + ) + ); + } + + function _createErc1155Contract(IZoraCreator1155Factory factory) private returns (IZoraCreator1155 target) { + // create the contract, with no toekns + bytes[] memory initSetup = new bytes[](0); - address admin = creator; uint32 royaltyMintSchedule = 10; uint32 royaltyBPS = 100; + + address admin = creator; string memory contractURI = "ipfs://asdfasdf"; string memory name = "Test"; address royaltyRecipient = creator; - string memory tokenURI = "ipfs://token"; - uint256 tokenMaxSupply = 100; - - // now create a contract with the factory - vm.startPrank(creator); - - IMinter1155 fixedPrice = factory.defaultMinters()[0]; - - // make sure that the address from the factory matches the stored fixed price address - assertEq(getDeployment().fixedPriceSaleStrategy, address(fixedPrice), string.concat("configured fixed price address incorrect on: ", chainName)); - - // ** 1. Create the erc1155 contract ** - - // create the contract, with no toekns - bytes[] memory initSetup = new bytes[](0); address deployedAddress = factory.createContract( contractURI, name, @@ -82,31 +85,37 @@ contract ZoraCreator1155FactoryForkTest is ForkDeploymentConfig, Test { initSetup ); - IZoraCreator1155 target = IZoraCreator1155(deployedAddress); + target = IZoraCreator1155(deployedAddress); // ** 2. Setup a new token with the fixed price sales strategy ** + } - uint256 tokenId = target.setupNewToken(tokenURI, tokenMaxSupply); + function testTheFork(string memory chainName) private { + console.log("testing on fork: ", chainName); - target.addPermission(tokenId, address(fixedPrice), PERMISSION_BIT_MINTER); + // create and select the fork, which will be used for all subsequent calls + // it will also affect the current block chain id based on the rpc url returned + vm.createSelectFork(vm.rpcUrl(chainName)); - uint96 tokenPrice = 1 ether; + address factoryAddress = getDeployment().factoryProxy; + IZoraCreator1155Factory factory = IZoraCreator1155Factory(factoryAddress); - target.callSale( - tokenId, - fixedPrice, - abi.encodeWithSelector( - ZoraCreatorFixedPriceSaleStrategy.setSale.selector, - tokenId, - ZoraCreatorFixedPriceSaleStrategy.SalesConfig({ - pricePerToken: tokenPrice, - saleStart: 0, - saleEnd: type(uint64).max, - maxTokensPerAddress: 0, - fundsRecipient: address(0) - }) - ) - ); + assertEq(getChainConfig().factoryOwner, IOwnable(factoryAddress).owner(), string.concat("configured owner incorrect on: ", chainName)); + + // now create a contract with the factory + vm.startPrank(creator); + + IMinter1155 fixedPrice = factory.defaultMinters()[0]; + + // make sure that the address from the factory matches the stored fixed price address + assertEq(getDeployment().fixedPriceSaleStrategy, address(fixedPrice), string.concat("configured fixed price address incorrect on: ", chainName)); + + // ** 1. Create the erc1155 contract ** + IZoraCreator1155 target = _createErc1155Contract(factory); + + // ** 2. Setup a new token with the fixed price sales strategy and the token price ** + uint96 tokenPrice = 1 ether; + uint256 tokenId = _setupToken(target, fixedPrice, tokenPrice); // ** 3. Mint on that contract **