Skip to content

Commit

Permalink
add forge test to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
godzillaba committed Oct 3, 2024
1 parent 0d210c6 commit 71aeeb5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NOVA_URL=
ARB_URL=
ETH_URL=
26 changes: 26 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions test/gov-actions/AIPNovaFeeRoutingAction.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)));
Expand All @@ -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,
Expand Down
34 changes: 9 additions & 25 deletions test/gov-actions/NomineeGovernorV2UpgradeAction.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -49,7 +42,7 @@ contract NomineeGovernorV2UpgradeActionTest is Test {

assertEq(
_getImplementation(),
newImplementation,
action.newNomineeElectionGovernorImplementation(),
"implementation not set"
);

Expand All @@ -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;
}
}
9 changes: 4 additions & 5 deletions test/gov-actions/SwitchManagerRolesAction.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 71aeeb5

Please sign in to comment.