Skip to content

Commit

Permalink
chore: add test with custom create referral
Browse files Browse the repository at this point in the history
  • Loading branch information
kulkarohan authored and oveddan committed Oct 17, 2023
1 parent 9be5628 commit 5ca081e
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,32 @@ contract ZoraCreator1155PreminterTest is ForkDeploymentConfig, Test {
});
}

function makeTokenCreationConfigWithCreateReferral(address createReferral) internal view returns (TokenCreationConfig memory) {
IMinter1155 fixedPriceMinter = factory.defaultMinters()[0];
return
TokenCreationConfig({
tokenURI: "blah.token",
maxSupply: 10,
maxTokensPerAddress: 5,
pricePerToken: 0,
mintStart: 0,
mintDuration: 0,
royaltyMintSchedule: defaultRoyaltyConfig.royaltyMintSchedule,
royaltyBPS: defaultRoyaltyConfig.royaltyBPS,
royaltyRecipient: defaultRoyaltyConfig.royaltyRecipient,
fixedPriceMinter: address(fixedPriceMinter),
createReferral: createReferral
});
}

function makeDefaultPremintConfig() internal view returns (PremintConfig memory) {
return PremintConfig({tokenConfig: makeDefaultTokenCreationConfig(), uid: 100, version: 0, deleted: false});
}

function makePremintConfigWithCreateReferral(address createReferral) internal view returns (PremintConfig memory) {
return PremintConfig({tokenConfig: makeTokenCreationConfigWithCreateReferral(createReferral), uid: 100, version: 0, deleted: false});
}

function test_successfullyMintsTokens() external {
// 1. Make contract creation params

Expand Down Expand Up @@ -729,6 +751,21 @@ contract ZoraCreator1155PreminterTest is ForkDeploymentConfig, Test {
preminter.premint{value: mintCost}(contractConfig, premintConfig2, newCreatorSignature, quantityToMint, "yo");
}

function testPremintWithCreateReferral() public {
address createReferral = makeAddr('createReferral');

ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig();
PremintConfig memory premintConfig = makePremintConfigWithCreateReferral(createReferral);

uint256 createdTokenId = _signAndExecutePremint(contractConfig, premintConfig, creatorPrivateKey, block.chainid, premintExecutor, 1, "hi");

ZoraCreator1155Impl createdContract = ZoraCreator1155Impl(preminter.getContractAddress(contractConfig));

address storedCreateReferral = createdContract.createReferrals(createdTokenId);

assertEq(storedCreateReferral, createReferral);
}

function _signAndExecutePremint(
ContractCreationConfig memory contractConfig,
PremintConfig memory premintConfig,
Expand Down

0 comments on commit 5ca081e

Please sign in to comment.