Skip to content

Commit

Permalink
remove need for env function in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramarti committed Oct 9, 2024
1 parent aa64924 commit 0eddd3e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions contracts/script/GenerateAlloc.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ contract GenerateAlloc is Script {
// Upgrade admin controls upgradeability (by being Owner of each ProxyAdmin),
// protocol admin is Owner of precompiles (admin/governance methods).
// To disable upgradeability, we transfer ProxyAdmin ownership to a dead address
address internal upgradeAdmin = vm.envAddress("UPGRADE_ADMIN_ADDRESS");
address internal protocolAdmin = vm.envAddress("ADMIN_ADDRESS");
address internal upgradeAdmin;
address internal protocolAdmin;
string internal dumpPath = getDumpPath();
bool public saveState = true;
uint256 public constant MAINNET_CHAIN_ID = 0; // TBD
Expand All @@ -47,6 +47,13 @@ contract GenerateAlloc is Script {
saveState = false;
}

/// @notice call from Test.sol only
function setAdminAddresses(address upgrade, address protocol) external {
require(block.chainid == 31337, "Only for local tests");
upgradeAdmin = upgrade;
protocolAdmin = protocol;
}

/// @notice path where alloc file will be stored
function getDumpPath() internal view returns (string memory) {
if (block.chainid == 1513) {
Expand All @@ -62,7 +69,14 @@ contract GenerateAlloc is Script {

/// @notice main script method
function run() public {
if (upgradeAdmin == address(0)) {
upgradeAdmin = vm.envAddress("UPGRADE_ADMIN_ADDRESS");
}
require(upgradeAdmin != address(0), "upgradeAdmin not set");

if (protocolAdmin == address(0)) {
protocolAdmin = vm.envAddress("ADMIN_ADDRESS");
}
require(protocolAdmin != address(0), "protocolAdmin not set");

vm.startPrank(deployer);
Expand Down
1 change: 1 addition & 0 deletions contracts/test/utils/Test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ contract Test is ForgeTest {
function setUp() virtual public {
GenerateAlloc initializer = new GenerateAlloc();
initializer.disableStateDump(); // Faster tests. Don't call to verify JSON output
initializer.setAdminAddresses(upgradeAdmin, admin);
initializer.run();
ipTokenStaking = IPTokenStaking(Predeploys.Staking);
ipTokenSlashing = IPTokenSlashing(Predeploys.Slashing);
Expand Down

0 comments on commit 0eddd3e

Please sign in to comment.