Skip to content

Commit

Permalink
chore: Extend post-vote tests (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgusakov authored Oct 17, 2024
1 parent 51e1406 commit bc6d134
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test-deployment *args:
forge test --match-path 'test/fork/*' --no-match-path='test/fork/voting/*' -vvv {{args}}

test-post-voting *args:
forge test --match-path 'test/fork/*' --no-match-path='test/fork/deployment/*' -vvv {{args}}
forge test --match-path 'test/fork/*' --no-match-path='test/fork/deployment/InitialState.t.sol' -vvv {{args}}

test-invariant *args:
forge test --match-path 'test/fork/invariant/*' -vvv {{args}}
Expand Down
81 changes: 81 additions & 0 deletions test/fork/deployment/InitialState.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import "forge-std/Test.sol";

import { Utilities } from "../../helpers/Utilities.sol";
import { DeploymentFixtures } from "../../helpers/Fixtures.sol";
import { DeployParams } from "../../../script/DeployBase.s.sol";
import { HashConsensus } from "../../../src/lib/base-oracle/HashConsensus.sol";
import { BaseOracle } from "../../../src/lib/base-oracle/BaseOracle.sol";
import { Slot } from "../../../src/lib/Types.sol";

contract ContractsInitialStateTest is Test, Utilities, DeploymentFixtures {
DeployParams private deployParams;

function setUp() public {
Env memory env = envVars();
vm.createSelectFork(env.RPC_URL);
initializeFromDeployment(env.DEPLOY_CONFIG);
deployParams = parseDeployParams(env.DEPLOY_CONFIG);
}

function test_module_initialState() public {
assertTrue(csm.isPaused());
assertFalse(csm.publicRelease());
assertEq(csm.getNodeOperatorsCount(), 0);
}

function test_acounting_initialState() public {
assertFalse(accounting.isPaused());
assertEq(accounting.totalBondShares(), 0);
assertEq(
accounting.getCurveInfo(earlyAdoption.CURVE_ID()).points,
deployParams.earlyAdoptionBondCurve
);
}

function test_feedistirbutor_initialState() public {
assertEq(feeDistributor.totalClaimableShares(), 0);
assertEq(feeDistributor.pendingSharesToDistribute(), 0);
assertEq(feeDistributor.treeRoot(), bytes32(0));
assertEq(
keccak256(abi.encodePacked(feeDistributor.treeCid())),
keccak256("")
);
}

function test_feeoracle_initialState() public {
assertFalse(oracle.isPaused());
(
bytes32 hash,
uint256 refSlot,
uint256 processingDeadlineTime,
bool processingStarted
) = oracle.getConsensusReport();
assertEq(hash, bytes32(0));
assertEq(refSlot, 0);
assertEq(processingDeadlineTime, 0);
assertFalse(processingStarted);
}

function test_hashconsensus_initialState() public {
vm.skip(block.chainid != 1);
assertEq(hashConsensus.getQuorum(), deployParams.hashConsensusQuorum);
(address[] memory members, ) = hashConsensus.getMembers();
assertEq(
keccak256(abi.encode(members)),
keccak256(abi.encode(deployParams.oracleMembers))
);

(members, ) = HashConsensus(
BaseOracle(locator.accountingOracle()).getConsensusContract()
).getMembers();
assertEq(
keccak256(abi.encode(members)),
keccak256(abi.encode(deployParams.oracleMembers))
);
}
}
58 changes: 0 additions & 58 deletions test/fork/deployment/PostDeployment.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ contract CSModuleDeploymentTest is Test, Utilities, DeploymentFixtures {
assertEq(csm.getRoleMemberCount(csm.RECOVERER_ROLE()), 0);
}

function test_initialState() public {
assertTrue(csm.isPaused());
assertFalse(csm.publicRelease());
assertEq(csm.getNodeOperatorsCount(), 0);
}

function test_proxy() public {
OssifiableProxy proxy = OssifiableProxy(payable(address(csm)));
assertEq(proxy.proxy__getAdmin(), address(deployParams.proxyAdmin));
Expand Down Expand Up @@ -248,15 +242,6 @@ contract CSAccountingDeploymentTest is Test, Utilities, DeploymentFixtures {
assertEq(accounting.getRoleMemberCount(accounting.RECOVERER_ROLE()), 0);
}

function test_initialState() public {
assertFalse(accounting.isPaused());
assertEq(accounting.totalBondShares(), 0);
assertEq(
accounting.getCurveInfo(earlyAdoption.CURVE_ID()).points,
deployParams.earlyAdoptionBondCurve
);
}

function test_proxy() public {
OssifiableProxy proxy = OssifiableProxy(payable(address(accounting)));
assertEq(proxy.proxy__getAdmin(), address(deployParams.proxyAdmin));
Expand Down Expand Up @@ -312,16 +297,6 @@ contract CSFeeDistributorDeploymentTest is Test, Utilities, DeploymentFixtures {
);
}

function test_initialState() public {
assertEq(feeDistributor.totalClaimableShares(), 0);
assertEq(feeDistributor.pendingSharesToDistribute(), 0);
assertEq(feeDistributor.treeRoot(), bytes32(0));
assertEq(
keccak256(abi.encodePacked(feeDistributor.treeCid())),
keccak256("")
);
}

function test_proxy() public {
OssifiableProxy proxy = OssifiableProxy(
payable(address(feeDistributor))
Expand Down Expand Up @@ -390,21 +365,6 @@ contract CSFeeOracleDeploymentTest is Test, Utilities, DeploymentFixtures {
);
}

function test_initialState() public {
assertFalse(oracle.isPaused());

(
bytes32 hash,
uint256 refSlot,
uint256 processingDeadlineTime,
bool processingStarted
) = oracle.getConsensusReport();
assertEq(hash, bytes32(0));
assertEq(refSlot, 0);
assertEq(processingDeadlineTime, 0);
assertFalse(processingStarted);
}

function test_proxy() public {
OssifiableProxy proxy = OssifiableProxy(payable(address(oracle)));
assertEq(proxy.proxy__getAdmin(), address(deployParams.proxyAdmin));
Expand Down Expand Up @@ -496,24 +456,6 @@ contract HashConsensusDeploymentTest is Test, Utilities, DeploymentFixtures {
0
);
}

function test_initialState() public {
vm.skip(block.chainid != 1);
assertEq(hashConsensus.getQuorum(), deployParams.hashConsensusQuorum);
(address[] memory members, ) = hashConsensus.getMembers();
assertEq(
keccak256(abi.encode(members)),
keccak256(abi.encode(deployParams.oracleMembers))
);

(members, ) = HashConsensus(
BaseOracle(locator.accountingOracle()).getConsensusContract()
).getMembers();
assertEq(
keccak256(abi.encode(members)),
keccak256(abi.encode(deployParams.oracleMembers))
);
}
}

contract CSEarlyAdoptionDeploymentTest is Test, Utilities, DeploymentFixtures {
Expand Down
5 changes: 5 additions & 0 deletions test/fork/deployment/Upgradability.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ contract UpgradabilityTest is Test, Utilities, DeploymentFixtures {
address contractAdmin = csm.getRoleMember(csm.DEFAULT_ADMIN_ROLE(), 0);
vm.startPrank(contractAdmin);
csm.grantRole(csm.RESUME_ROLE(), address(proxy.proxy__getAdmin()));
csm.grantRole(csm.PAUSE_ROLE(), address(proxy.proxy__getAdmin()));
vm.stopPrank();
if (!csm.isPaused()) {
vm.prank(proxy.proxy__getAdmin());
csm.pauseFor(100500);
}
assertTrue(csm.isPaused());
vm.prank(proxy.proxy__getAdmin());
proxy.proxy__upgradeToAndCall(
Expand Down

0 comments on commit bc6d134

Please sign in to comment.