From 71aeeb5bfc945d6cece6b14f92d241372bbcf62f Mon Sep 17 00:00:00 2001 From: Henry <11198460+godzillaba@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:14:58 -0400 Subject: [PATCH 1/2] add forge test to ci --- .env.example | 3 ++ .github/workflows/build-test.yml | 26 ++++++++++++++ .../gov-actions/AIPNovaFeeRoutingAction.t.sol | 12 +++---- .../NomineeGovernorV2UpgradeAction.t.sol | 34 +++++-------------- .../SwitchManagerRolesAction.t.sol | 9 +++-- 5 files changed, 48 insertions(+), 36 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..a525b410 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +NOVA_URL= +ARB_URL= +ETH_URL= \ No newline at end of file diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 5a743389..1be9475d 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -61,6 +61,32 @@ jobs: - name: Run build --sizes run: FOUNDRY_PROFILE=sec_council_mgmt forge build --sizes + test-foundry: + name: Test foundry + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Setup node/yarn + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'yarn' + cache-dependency-path: '**/yarn.lock' + + - name: Install packages + run: yarn + + - name: forge test + run: forge test + test-gas: name: Test gas runs-on: ubuntu-latest diff --git a/test/gov-actions/AIPNovaFeeRoutingAction.t.sol b/test/gov-actions/AIPNovaFeeRoutingAction.t.sol index 93b79753..d8058609 100644 --- a/test/gov-actions/AIPNovaFeeRoutingAction.t.sol +++ b/test/gov-actions/AIPNovaFeeRoutingAction.t.sol @@ -11,11 +11,11 @@ import "../../src/UpgradeExecutor.sol"; contract AIPNovaFeeRoutingActionTest is Test { UpgradeExecutor constant upExec = UpgradeExecutor(0x86a02dD71363c440b21F4c0E5B2Ad01Ffe1A7482); - function testAction() public { - if (!isFork()) { - return; - } + function setUp() public { + vm.createSelectFork(vm.envString("NOVA_URL"), 74298960); + } + function testAction() public { AIPNovaFeeRoutingAction action = new AIPNovaFeeRoutingAction(); // before we run the action, we need to make sure the upgrade executor has at least this much ETH @@ -26,7 +26,7 @@ contract AIPNovaFeeRoutingActionTest is Test { // make sure the new recipients are set - address[1] memory expectedL1SurplusRecipients = [0xd9a2e0E5d7509F0BF1B2d33884F8C1b4D4490879]; + address[1] memory expectedL1SurplusRecipients = [0x36D0170D92F66e8949eB276C3AC4FEA64f83704d]; uint256[1] memory expectedL1SurplusWeights = [uint(10_000)]; assertEq(IRewardDistributor(action.novaL1SurplusFeeDistr()).currentRecipientGroup(), keccak256(abi.encodePacked(expectedL1SurplusRecipients))); @@ -36,7 +36,7 @@ contract AIPNovaFeeRoutingActionTest is Test { address[7] memory expectedBaseFeeRecipients = [ - 0xd9a2e0E5d7509F0BF1B2d33884F8C1b4D4490879, // nova to l1 router + 0x36D0170D92F66e8949eB276C3AC4FEA64f83704d, // nova to l1 router 0xD0749b3e537Ed52DE4e6a3Ae1eB6fc26059d0895, // rest are same as current 0x41C327d5fc9e29680CcD45e5E52446E0DB3DAdFd, 0x02C2599aa929e2509741b44F3a13029745aB1AB2, diff --git a/test/gov-actions/NomineeGovernorV2UpgradeAction.t.sol b/test/gov-actions/NomineeGovernorV2UpgradeAction.t.sol index d4e5fdf3..f8efe0a3 100644 --- a/test/gov-actions/NomineeGovernorV2UpgradeAction.t.sol +++ b/test/gov-actions/NomineeGovernorV2UpgradeAction.t.sol @@ -16,23 +16,16 @@ contract NomineeGovernorV2UpgradeActionTest is Test { // see https://github.com/ArbitrumFoundation/docs/pull/731/commits/0837520dccc12e56a25f62de90ff9e3869196d05 bytes32 newConstitutionHash = 0xe794b7d0466ffd4a33321ea14c307b2de987c3229cf858727052a6f4b8a19cc1; - address newImplementation = address(new SecurityCouncilNomineeElectionGovernor()); - uint256 votingDelay = 7 days; - NomineeGovernorV2UpgradeActionTemplate action = new NomineeGovernorV2UpgradeActionTemplate( - address(proxyAdmin), - address(gov), - newImplementation, - votingDelay, - address(constitution), - newConstitutionHash - ); + uint256 votingDelay = 50400; + NomineeGovernorV2UpgradeAction action; - function testAction() external { - if (!_isForkTest()) { - console.log("not fork test, skipping NomineeGovernorV2UpgradeActionTest"); - return; - } + function setUp() external { + vm.createSelectFork(vm.envString("ARB_URL"), 173727923); + + action = new NomineeGovernorV2UpgradeAction(); + } + function testAction() external { if (_getImplementation() != oldImplementation) { console.log("implementation not set to old implementation, skipping NomineeGovernorV2UpgradeActionTest"); return; @@ -49,7 +42,7 @@ contract NomineeGovernorV2UpgradeActionTest is Test { assertEq( _getImplementation(), - newImplementation, + action.newNomineeElectionGovernorImplementation(), "implementation not set" ); @@ -63,13 +56,4 @@ contract NomineeGovernorV2UpgradeActionTest is Test { function _getImplementation() internal view returns (address) { return proxyAdmin.getProxyImplementation(TransparentUpgradeableProxy(payable(gov))); } - - function _isForkTest() internal view returns (bool) { - bool isForkTest; - address _gov = address(gov); - assembly { - isForkTest := gt(extcodesize(_gov), 0) - } - return isForkTest; - } } diff --git a/test/gov-actions/SwitchManagerRolesAction.t.sol b/test/gov-actions/SwitchManagerRolesAction.t.sol index d3602138..d76069ec 100644 --- a/test/gov-actions/SwitchManagerRolesAction.t.sol +++ b/test/gov-actions/SwitchManagerRolesAction.t.sol @@ -8,12 +8,11 @@ import "../../src/gov-action-contracts/nonemergency/SwitchManagerRolesAction.sol contract SwitchManagerRolesActionTest is Test { UpgradeExecutor arbOneUe = UpgradeExecutor(0xCF57572261c7c2BCF21ffD220ea7d1a27D40A827); - function testAction() external { - if (!isFork()) { - console.log("not fork test, skipping SwitchManagerRolesActionTest"); - return; - } + function setUp() external { + vm.createSelectFork(vm.envString("ARB_URL"), 221131972); + } + function testAction() external { SwitchManagerRolesAction gac = new SwitchManagerRolesAction(); address emergencyCouncil = gac.emergencyCouncil(); From 9b2700573ca8963b489422a85a534911139b978d Mon Sep 17 00:00:00 2001 From: Henry <11198460+godzillaba@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:17:30 -0400 Subject: [PATCH 2/2] remove new ci job --- .github/workflows/build-test.yml | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 1be9475d..5a743389 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -61,32 +61,6 @@ jobs: - name: Run build --sizes run: FOUNDRY_PROFILE=sec_council_mgmt forge build --sizes - test-foundry: - name: Test foundry - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - - name: Setup node/yarn - uses: actions/setup-node@v3 - with: - node-version: 16 - cache: 'yarn' - cache-dependency-path: '**/yarn.lock' - - - name: Install packages - run: yarn - - - name: forge test - run: forge test - test-gas: name: Test gas runs-on: ubuntu-latest