Skip to content

Commit

Permalink
Fixed deployment script test
Browse files Browse the repository at this point in the history
  • Loading branch information
drinkcoffee committed Oct 21, 2024
1 parent 2df5696 commit df05715
Showing 1 changed file with 32 additions and 35 deletions.
67 changes: 32 additions & 35 deletions script/staking/DeployStakeHolder.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.8.20;

import "forge-std/Test.sol";
Expand Down Expand Up @@ -37,41 +36,39 @@ struct StakeHolderContractArgs {
address upgradeAdmin;
}

/**
* @notice Deployment script and test code for the deployment script.
* @dev testDeploy is the test.
* @dev deploy() is the function the script should call:
*
*/
contract DeployStakeHolder is Test {
// function testDeploy() external {
// /// @dev Fork the Immutable zkEVM testnet for this test
// string memory rpcURL = "https://rpc.testnet.immutable.com";
// vm.createSelectFork(rpcURL);

// /// @dev These are Immutable zkEVM testnet values where necessary
// DeploymentArgs memory deploymentArgs = DeploymentArgs({
// signer: 0xdDA0d9448Ebe3eA43aFecE5Fa6401F5795c19333,
// factory: 0x37a59A845Bb6eD2034098af8738fbFFB9D589610,
// salt1: "salt1",
// salt2: "salt2"
// });

// StakeHolderContractArgs memory stakeHolderContractArgs = StakeHolderContractArgs({
// roleAdmin: makeAddr("role"),
// upgradeAdmin: makeAddr("upgrade")
// });

// // Run deployment against forked testnet
// StakeHolder deployedContract = _deploy(deploymentArgs, stakeHolderContractArgs);

// assertEq(true, deployedContract.hasRole(keccak256("UPGRADE"), stakeHolderContractArgs.upgradeAdmin));
// assertEq(
// true,
// deployedContract.hasRole(
// deployedContract.DEFAULT_ADMIN_ROLE(), stakeHolderContractArgs.roleAdmin
// )
// );

// // The DEFAULT_ADMIN_ROLE should be revoked from the deployer account
// assertEq(
// false, deployedContract.hasRole(deployedContract.DEFAULT_ADMIN_ROLE(), deploymentArgs.signer)
// );
// }
function testDeploy() external {
/// @dev Fork the Immutable zkEVM testnet for this test
string memory rpcURL = "https://rpc.testnet.immutable.com";
vm.createSelectFork(rpcURL);

/// @dev These are Immutable zkEVM testnet values where necessary
DeploymentArgs memory deploymentArgs = DeploymentArgs({
signer: 0xdDA0d9448Ebe3eA43aFecE5Fa6401F5795c19333,
factory: 0x37a59A845Bb6eD2034098af8738fbFFB9D589610,
salt1: "salt1",
salt2: "salt2"
});

StakeHolderContractArgs memory stakeHolderContractArgs = StakeHolderContractArgs({
roleAdmin: makeAddr("role"),
upgradeAdmin: makeAddr("upgrade")
});

// Run deployment against forked testnet
StakeHolder deployedContract = _deploy(deploymentArgs, stakeHolderContractArgs);

assertTrue(deployedContract.hasRole(deployedContract.UPGRADE_ROLE(), stakeHolderContractArgs.upgradeAdmin), "Upgrade admin should have upgrade role");
assertTrue(deployedContract.hasRole(deployedContract.DEFAULT_ADMIN_ROLE(), stakeHolderContractArgs.roleAdmin), "Role admin should have default admin role");
// The DEFAULT_ADMIN_ROLE should be revoked from the deployer account
assertFalse(deployedContract.hasRole(deployedContract.DEFAULT_ADMIN_ROLE(), deploymentArgs.signer), "msg.sender should not be an admin");
}

function deploy() external {
address signer = vm.envAddress("DEPLOYER_ADDRESS");
Expand Down

0 comments on commit df05715

Please sign in to comment.