Skip to content

Commit

Permalink
Fix fork tests.
Browse files Browse the repository at this point in the history
Update fork tests to just test deployments package
  • Loading branch information
oveddan committed Oct 31, 2023
1 parent e8e45bd commit f798042
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ jobs:
run: |
npx turbo run test:fork
env:
FORK_TEST_CHAINS: mainnet,goerli,optimism,optimism_goerli,zora,zora_goerli,base_goerli,base
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}

storage_layout:
Expand Down
2 changes: 0 additions & 2 deletions packages/1155-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"types": "./dist/package/index.d.ts",
"type": "module",
"scripts": {
"test": "forge test",
"dev": "FOUNDRY_PROFILE=dev forge test --watch -vvv",
"test:fork": "forge test -vvv --match-test fork",
"test-gas": "forge test --gas-report",
"prettier:check": "prettier --check 'src/**/*.sol' 'test/**/*.sol' 'package/**/*.ts' 'wagmi.config.ts'",
"prettier": "prettier --write 'src/**/*.sol' 'test/**/*.sol' 'package/**/*.ts' 'script/**/*.ts' 'wagmi.config.ts'",
Expand Down
2 changes: 2 additions & 0 deletions packages/deployments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"type": "module",
"scripts": {
"dev": "FOUNDRY_PROFILE=dev forge test --watch -vvv",
"test:fork": "FORK_TEST_CHAINS=mainnet,goerli,optimism,optimism_goerli,zora,zora_goerli,base_goerli,base forge test -vvv",
"test": "forge test -vvv",
"build": "yarn wagmi && yarn bundle-configs && tsup",
"bundle-configs": "node script/bundle-chainConfigs.mjs && yarn prettier",
"prettier": "prettier --write 'package/**/*.ts' 'script/**/*.ts' 'wagmi.config.ts'",
Expand Down
32 changes: 29 additions & 3 deletions packages/deployments/src/DeploymentTestingUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ pragma solidity ^0.8.13;

import "forge-std/Script.sol";
import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1155.sol";
import {Zora1155PremintFixtures} from "@zoralabs/zora-1155-contracts/src/@zoralabs/zora-1155-contracts/src/test/fixtures/Zora1155PremintFixtures.sol";
import {ZoraCreator1155PremintExecutorImpl} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol";
import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
import {ZoraCreator1155Attribution, ContractCreationConfig, PremintConfig} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";
import {ZoraCreator1155Impl} from "@zoralabs/zora-1155-contracts/src/nft/ZoraCreator1155Impl.sol";
import {ICreatorRoyaltiesControl} from "@zoralabs/zora-1155-contracts/src/interfaces/ICreatorRoyaltiesControl.sol";
import {ContractCreationConfig, TokenCreationConfig, PremintConfig} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";

contract DeploymentTestingUtils is Script {
function signAndExecutePremint(address premintExecutorProxyAddress) internal {
Expand All @@ -19,14 +20,14 @@ contract DeploymentTestingUtils is Script {
IMinter1155 fixedPriceMinter = ZoraCreator1155FactoryImpl(address(preminterAtProxy.zora1155Factory())).fixedPriceMinter();

PremintConfig memory premintConfig = PremintConfig({
tokenConfig: Zora1155PremintFixtures.makeDefaultTokenCreationConfig(fixedPriceMinter, creator),
tokenConfig: _makeDefaultTokenCreationConfig(fixedPriceMinter, creator),
uid: 100,
version: 0,
deleted: false
});

// now interface with proxy preminter - sign and execute the premint
ContractCreationConfig memory contractConfig = Zora1155PremintFixtures.makeDefaultContractCreationConfig(creator);
ContractCreationConfig memory contractConfig = _makeDefaultContractCreationConfig(creator);
address deterministicAddress = preminterAtProxy.getContractAddress(contractConfig);

// sign the premint
Expand All @@ -43,4 +44,29 @@ contract DeploymentTestingUtils is Script {

require(ZoraCreator1155Impl(deterministicAddress).delegatedTokenId(premintConfig.uid) == tokenId, "token id not created for uid");
}

function _makeDefaultContractCreationConfig(address contractAdmin) internal pure returns (ContractCreationConfig memory) {
return ContractCreationConfig({contractAdmin: contractAdmin, contractName: "blah", contractURI: "blah.contract"});
}

function _defaultRoyaltyConfig(address royaltyRecipient) internal pure returns (ICreatorRoyaltiesControl.RoyaltyConfiguration memory) {
return ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyBPS: 10, royaltyRecipient: royaltyRecipient, royaltyMintSchedule: 0});
}

function _makeDefaultTokenCreationConfig(IMinter1155 fixedPriceMinter, address royaltyRecipient) internal pure returns (TokenCreationConfig memory) {
ICreatorRoyaltiesControl.RoyaltyConfiguration memory royaltyConfig = _defaultRoyaltyConfig(royaltyRecipient);
return
TokenCreationConfig({
tokenURI: "blah.token",
maxSupply: 10,
maxTokensPerAddress: 5,
pricePerToken: 0,
mintStart: 0,
mintDuration: 0,
royaltyMintSchedule: royaltyConfig.royaltyMintSchedule,
royaltyBPS: royaltyConfig.royaltyBPS,
royaltyRecipient: royaltyConfig.royaltyRecipient,
fixedPriceMinter: address(fixedPriceMinter)
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
pragma solidity 0.8.17;

import "forge-std/Test.sol";
import {ForkDeploymentConfig} from "../src/DeploymentConfig.sol";
import {ZoraCreator1155Attribution, ContractCreationConfig, PremintConfig, TokenCreationConfig} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155Attribution.sol";
import {ZoraCreator1155PremintExecutorImpl} from "@zoralabs/zora-1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol";
import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";

contract ZoraCreator1155PreminterForkTest is ForkDeploymentConfig, Test {
ZoraCreator1155FactoryImpl factory;
ZoraCreator1155PremintExecutorImpl preminter;
uint256 mintFeeAmount = 0.000777 ether;

/// @notice gets the chains to do fork tests on, by reading environment var FORK_TEST_CHAINS.
/// Chains are by name, and must match whats under `rpc_endpoints` in the foundry.toml
function getForkTestChains() private view returns (string[] memory result) {
Expand Down

0 comments on commit f798042

Please sign in to comment.