Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iainnash committed Jul 18, 2023
1 parent 401cbdb commit 9b1ae84
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addresses/84531.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"DROP_METADATA_RENDERER": "0x0Cf8733DEd6d9E0905A8cCc8DC767F381A76970a",
"EDITION_METADATA_RENDERER": "0xC5c958a65656A84b74100D1d420a1819fEA18d41",
"ERC721DROP_IMPL": "0x824dD1cCd0824A15913B454A7E5D3Bf0C6b2BeEd",
"ERC721DROP_IMPL": "0x824dd1ccd0824a15913b454a7e5d3bf0c6b2beed",
"FACTORY_UPGRADE_GATE": "0x3C1ebcF36Ca9DD9371c9aA99c274e4988906c6E3",
"ZORA_NFT_CREATOR_PROXY": "0x87cfd516c5ea86e50b950678CA970a8a28de27ac",
"ZORA_NFT_CREATOR_V1_IMPL": "0x2E0c148C1AeD0360Df9a86112fD7C4EAb8045779"
"ZORA_NFT_CREATOR_V1_IMPL": "0xf0fd838913e9407edac7e51629de21eaf748b50a"
}
166 changes: 166 additions & 0 deletions test/ZoraNFTCreatorV1_fork.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {console2} from "forge-std/console2.sol";
import {Test} from "forge-std/Test.sol";
import {IMetadataRenderer} from "../src/interfaces/IMetadataRenderer.sol";
import "../src/ZoraNFTCreatorV1.sol";
import "../src/ZoraNFTCreatorProxy.sol";
import {MockMetadataRenderer} from "./metadata/MockMetadataRenderer.sol";
import {FactoryUpgradeGate} from "../src/FactoryUpgradeGate.sol";
import {IERC721AUpgradeable} from "erc721a-upgradeable/IERC721AUpgradeable.sol";
import {ForkHelper} from "./utils/ForkHelper.sol";
import {DropDeployment, ChainConfig} from "../src/DeploymentConfig.sol";

contract ZoraNFTCreatorV1Test is Test, ForkHelper {
address public constant DEFAULT_OWNER_ADDRESS = address(0x23499);
address payable public constant DEFAULT_FUNDS_RECIPIENT_ADDRESS = payable(address(0x21303));
address payable public constant DEFAULT_ZORA_DAO_ADDRESS = payable(address(0x999));
address payable public constant mintFeeRecipient = payable(address(0x1234));
uint256 public constant mintFee = 0.000777 ether;
ERC721Drop public dropImpl;
ZoraNFTCreatorV1 public creator;
EditionMetadataRenderer public editionMetadataRenderer;
DropMetadataRenderer public dropMetadataRenderer;

function test_fork_create() external {
string[] memory forkTestChains = getForkTestChains();

for (uint256 i = 0; i < forkTestChains.length; i++) {
string memory chainName = forkTestChains[i];

vm.createSelectFork(vm.rpcUrl(chainName));
creator = ZoraNFTCreatorV1(getDeployment().factory);
verifyAddressesFork(chainName);
forkEdition();
forkDrop();
forkDropGeneric();
}
}

function verifyAddressesFork(string memory chainName) internal {
ChainConfig memory chainConfig = getChainConfig();
DropDeployment memory deployment = getDeployment();

assertEq(chainConfig.factoryOwner, OwnableUpgradeable(deployment.factory).owner(), string.concat("configured owner incorrect on: ", chainName));

bytes32 slot = UUPSUpgradeable(deployment.factoryImpl).proxiableUUID();
address factoryImpl = address(uint160(uint256(vm.load(deployment.factory, slot))));
if (factoryImpl != deployment.factoryImpl) {

console2.log("===========");
console2.log("===========");
console2.log("FACTORY IMPL NOT SAME AS CHAIN: SIMULATING UPGRADE STEP");
console2.log("to save changes: call upgradeTo(", deployment.factoryImpl, ")");
console2.log("on ", deployment.factory);
console2.log("chain: ", chainName);
console2.log("===========");
console2.log("===========");

creator = ZoraNFTCreatorV1(deployment.factory);
vm.prank(creator.owner());
creator.upgradeTo(deployment.factoryImpl);
}

assertEq(
deployment.dropMetadata,
address(creator.dropMetadataRenderer()),
string.concat("configured drop metadata renderer incorrect on: ", chainName)
);
assertEq(
deployment.editionMetadata,
address(creator.editionMetadataRenderer()),
string.concat("configured edition metadata renderer incorrect on: ", chainName)
);
assertEq(deployment.dropImplementation, address(creator.implementation()), string.concat("configured metadata renderer incorrect on: ", chainName));
}

function forkEdition() internal {
address deployedEdition = creator.createEdition(
"name",
"symbol",
100,
500,
DEFAULT_FUNDS_RECIPIENT_ADDRESS,
DEFAULT_FUNDS_RECIPIENT_ADDRESS,
IERC721Drop.SalesConfiguration({
publicSaleStart: 0,
publicSaleEnd: type(uint64).max,
presaleStart: 0,
presaleEnd: 0,
publicSalePrice: 0.1 ether,
maxSalePurchasePerAddress: 0,
presaleMerkleRoot: bytes32(0)
}),
"desc",
"animation",
"image"
);
ERC721Drop drop = ERC721Drop(payable(deployedEdition));
(, uint256 fee) = drop.zoraFeeForAmount(10);
vm.startPrank(DEFAULT_FUNDS_RECIPIENT_ADDRESS);
vm.deal(DEFAULT_FUNDS_RECIPIENT_ADDRESS, 10 ether + fee);
drop.purchase{value: 1 ether + fee}(10);
assertEq(drop.totalSupply(), 10);
}

function forkDrop() internal {
address deployedDrop = creator.createDrop(
"name",
"symbol",
DEFAULT_FUNDS_RECIPIENT_ADDRESS,
1000,
100,
DEFAULT_FUNDS_RECIPIENT_ADDRESS,
IERC721Drop.SalesConfiguration({
publicSaleStart: 0,
publicSaleEnd: type(uint64).max,
presaleStart: 0,
presaleEnd: 0,
publicSalePrice: 0,
maxSalePurchasePerAddress: 0,
presaleMerkleRoot: bytes32(0)
}),
"metadata_uri",
"metadata_contract_uri"
);
ERC721Drop drop = ERC721Drop(payable(deployedDrop));
(, uint256 fee) = drop.zoraFeeForAmount(10);
drop.purchase{value: fee}(10);
assertEq(drop.totalSupply(), 10);
}

function forkDropGeneric() internal {
MockMetadataRenderer mockRenderer = new MockMetadataRenderer();
address deployedDrop = creator.setupDropsContract(
"name",
"symbol",
DEFAULT_FUNDS_RECIPIENT_ADDRESS,
1000,
100,
DEFAULT_FUNDS_RECIPIENT_ADDRESS,
IERC721Drop.SalesConfiguration({
publicSaleStart: 0,
publicSaleEnd: type(uint64).max,
presaleStart: 0,
presaleEnd: 0,
publicSalePrice: 0,
maxSalePurchasePerAddress: 0,
presaleMerkleRoot: bytes32(0)
}),
mockRenderer,
""
);
ERC721Drop drop = ERC721Drop(payable(deployedDrop));
ERC721Drop.SaleDetails memory saleDetails = drop.saleDetails();
assertEq(saleDetails.publicSaleStart, 0);
assertEq(saleDetails.publicSaleEnd, type(uint64).max);

vm.expectRevert(IERC721AUpgradeable.URIQueryForNonexistentToken.selector);
drop.tokenURI(1);
assertEq(drop.contractURI(), "DEMO");
(, uint256 fee) = drop.zoraFeeForAmount(1);
drop.purchase{value: fee}(1);
assertEq(drop.tokenURI(1), "DEMO");
}
}

0 comments on commit 9b1ae84

Please sign in to comment.