Skip to content

Commit

Permalink
Merge pull request #167 from ourzora/add-back-coverage
Browse files Browse the repository at this point in the history
Add back coverage ci task, and fix fork tests to not run into compliation issues when running coverage report
  • Loading branch information
kulkarohan authored Sep 12, 2023
2 parents 4c0982c + 9bcfccc commit 65775c4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: ./
95 changes: 52 additions & 43 deletions test/factory/ZoraCreator1155Factory_Fork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 **

Expand Down

0 comments on commit 65775c4

Please sign in to comment.