Skip to content

Commit

Permalink
++ L2 test
Browse files Browse the repository at this point in the history
  • Loading branch information
soloseng committed Feb 4, 2025
1 parent 0ba8c29 commit c9e8e85
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ contract MockEpochManager is IEpochManager {
numberOfElectedAccounts = value;
}

function setElectedAccounts(address[] calldata _electedAccounts) external {
electedAccounts = _electedAccounts;
}

function setElectedSigners(address[] calldata _electedSigners) external {
electedSigners = _electedSigners;
}

function getCurrentEpoch() external view returns (uint256, uint256, uint256, uint256) {
return getEpochByNumber(currentEpochNumber);
}
Expand Down
20 changes: 18 additions & 2 deletions packages/protocol/test-sol/unit/governance/voting/Election.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "@celo-contracts/common/Accounts.sol";
import "@celo-contracts/common/linkedlists/AddressSortedLinkedList.sol";
import "@celo-contracts/identity/test/MockRandom.sol";
import "@celo-contracts/common/Freezer.sol";
import "@test-sol/unit/common/mocks/MockEpochManager.sol";
// import "@test-sol/unit/common/mocks/MockEpochManager.sol";
import "@test-sol/utils/WhenL2.sol";

import { TestBlocker } from "@test-sol/unit/common/Blockable.t.sol";
Expand Down Expand Up @@ -57,7 +57,7 @@ contract ElectionTest is TestWithUtils {
address account9 = actor("account9");
address account10 = actor("account10");

address epochManagerAddress = actor("epochManagerAddress");
// address epochManagerAddress = actor("epochManagerAddress");

address[] accountsArray;

Expand Down Expand Up @@ -1937,6 +1937,22 @@ contract ElectionTest_ElectValidatorsAccountsL2 is
ElectionTest_L2
{}

contract ElectionTest_GetCurrentValidatorSigners_L2 is
ElectionTest_L2,
ElectionTest_ElectValidatorsAbstract
{
function test_ShouldReturnValidatorSigners() public {
WhenThereIsALargeNumberOfGroups();
address[] memory elected = election.electValidatorAccounts();
epochManager.setElectedAccounts(elected);
epochManager.setElectedSigners(elected);
epochManager.setNumberOfElectedInCurrentSet(epochManager.getElectedAccounts().length);
address[] memory electedInCurrentSet = election.getCurrentValidatorSigners();

assertEq(elected, electedInCurrentSet);
}
}

contract ElectionTest_GetGroupEpochRewards is ElectionTest {
address voter = address(this);
address group1 = account2;
Expand Down

0 comments on commit c9e8e85

Please sign in to comment.