Skip to content

Commit

Permalink
test: add option to get system admin from env var
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-fruitful committed Jul 25, 2023
1 parent bde2d24 commit f49c661
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export ETH_SEPOLIA_RPC_URL=
export ETHERSCAN_API_KEY=
export NAYMS_SALT=
export OWNER_ACCOUNT_KEY=
export SYSTEM_ADMIN_1=
export FORK_BLOCK_1=
export FORK_BLOCK_11155111=
export FORK_BLOCK_31337=
13 changes: 9 additions & 4 deletions test/defaults/D01Deployment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,36 @@ abstract contract D01Deployment is D00GlobalDefaults, DeploymentHelpers {
}

constructor() payable {
console2.log("block.chainid", block.chainid);

uint256 FORK_BLOCK = vm.envOr({ name: string.concat("FORK_BLOCK_", vm.toString(block.chainid)), defaultValue: type(uint256).max });

console2.log("FORK_BLOCK", FORK_BLOCK);

if (block.chainid != 0) {
if (FORK_BLOCK == type(uint256).max) {
console2.log("Using latest block for fork, consider pinning a block number to avoid overloading the RPC endpoint");
vm.createSelectFork(getChain(block.chainid).rpcUrl);
} else {
vm.createSelectFork(getChain(block.chainid).rpcUrl, FORK_BLOCK);
}
naymsAddress = 0x39e2f550fef9ee15b459d16bD4B243b04b1f60e5;
naymsAddress = getDiamondAddressFromFile();
nayms = INayms(naymsAddress);

deployer = address(this);
owner = nayms.owner();
vm.label(owner, "Owner");
systemAdmin = 0xE6aD24478bf7E1C0db07f7063A4019C83b1e5929;
systemAdmin = vm.envOr({ name: string.concat("SYSTEM_ADMIN_", vm.toString(block.chainid)), defaultValue: address(0xE6aD24478bf7E1C0db07f7063A4019C83b1e5929) });
systemAdminId = LibHelpers._getIdForAddress(systemAdmin);
vm.label(systemAdmin, "System Admin");

string[] memory facetsToCutIn;
keyToReadDiamondAddress = string.concat(".", vm.toString(block.chainid));
IDiamondCut.FacetCut[] memory cut = facetDeploymentAndCut(getDiamondAddressFromFile(), FacetDeploymentAction.UpgradeFacetsWithChangesOnly, facetsToCutIn);
IDiamondCut.FacetCut[] memory cut = facetDeploymentAndCut(naymsAddress, FacetDeploymentAction.UpgradeFacetsWithChangesOnly, facetsToCutIn);
vm.startPrank(owner);
scheduleAndUpgradeDiamond(cut);
} else {
console2.log("Isolated testing (no fork)");
console2.log("Local testing (no fork)");

deployer = address(this);
owner = address(this);
Expand Down

0 comments on commit f49c661

Please sign in to comment.