Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soloseng/L2-scoreManager-test #11313

Open
wants to merge 33 commits into
base: release/core-contracts/12
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
caa2a2f
Merge remote-tracking branch 'origin/release/core-contracts/12' into …
soloseng Nov 21, 2024
4f4a917
WIP inheritance issues ?
soloseng Nov 22, 2024
75d40e9
Merge branch 'release/core-contracts/12' into soloseng/L2-FeeCurrency…
soloseng Dec 16, 2024
4a2c7f7
fixing compilation
soloseng Dec 20, 2024
d8a532f
removed mento from UsingRegistryV2 in 08
soloseng Dec 21, 2024
afe5356
using local precompile handler
soloseng Jan 7, 2025
23bd832
fixed unit test inheritance conflicts
soloseng Jan 7, 2025
e85910d
removed shadowed var
soloseng Jan 7, 2025
8b6b836
passing devchain e2e
soloseng Jan 7, 2025
5b3dd2d
passing migration test
soloseng Jan 7, 2025
ee99877
override Utils08 setup and cleanup
soloseng Jan 8, 2025
97d7ef3
change Utils08 filename
soloseng Jan 8, 2025
c519fa9
Merge remote-tracking branch 'origin/release/core-contracts/12' into …
soloseng Jan 8, 2025
3fa7426
Merge branch 'soloseng/L2-FeeCurrencyDirectory-test' into soloseng/fi…
soloseng Jan 8, 2025
48f0b7f
passing devchain
soloseng Jan 10, 2025
bf5de2d
reorg TestWithUtils08
soloseng Jan 10, 2025
4322801
Passing L2 epochManagerEnabler test
soloseng Jan 10, 2025
99f09b2
renamed to force update
soloseng Jan 13, 2025
da2d92a
using capital letter
soloseng Jan 13, 2025
5581845
Merge branch 'soloseng/fix-precompile-inheritance' into soloseng/L2-e…
soloseng Jan 13, 2025
21ad790
wip partially migrated without mockAccounts contract
soloseng Jan 14, 2025
f44045c
++ finish epoch processing L2 test
soloseng Jan 15, 2025
24b9f96
clean up setup
soloseng Jan 15, 2025
8f2fcf5
++ more working L1 & L2 test
soloseng Jan 16, 2025
0b31d9c
++ remaining L2 tests
soloseng Jan 16, 2025
286e569
clean up comments
soloseng Jan 16, 2025
c2af92f
more clean up
soloseng Jan 16, 2025
d5d1178
PR feedback
soloseng Jan 21, 2025
56cd4a6
initialized `celoToken` & `celoUnreleasedTreasury` in `TestWithUtils08`
soloseng Jan 21, 2025
d7e5b7c
passing tests
soloseng Jan 21, 2025
81bef3a
clean up
soloseng Jan 22, 2025
8e1d82a
Merge remote-tracking branch 'origin/release/core-contracts/12' into …
soloseng Jan 27, 2025
2d772df
Fix e2e test
soloseng Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
++ remaining L2 tests
  • Loading branch information
soloseng committed Jan 16, 2025
commit 0b31d9ca37cc09d3519e1c022e28998145997b07
232 changes: 135 additions & 97 deletions packages/protocol/test-sol/unit/common/EpochManager.t.sol
Original file line number Diff line number Diff line change
@@ -979,15 +979,9 @@ contract EpochManagerTest_processGroup_L2 is EpochManagerTest_L2 {

contract EpochManagerTest_getEpochByNumber is EpochManagerTest {
function test_Reverts_onL1() public {
uint256 numberOfEpochsToTravel = 9;
vm.expectRevert("Epoch system not initialized");

(
uint256 _firstBlock,
uint256 _lastBlock,
uint256 _startTimestamp,
uint256 _rewardBlock
) = epochManagerContract.getEpochByNumber(9);
epochManagerContract.getEpochByNumber(9);
}
}
contract EpochManagerTest_getEpochByNumber_L2 is EpochManagerTest_L2 {
@@ -1030,12 +1024,8 @@ contract EpochManagerTest_getEpochByNumber_L2 is EpochManagerTest_L2 {
uint256 _startingEpochNumber = epochManagerContract.getCurrentEpochNumber();
console.log("current block", block.number);
uint256 numberOfEpochsToTravel = 7;
(
uint256 _startingEpochFirstBlock,
uint256 _startingLastBlock,
uint256 _startingStartTimestamp,
uint256 _startingRewardBlock
) = epochManagerContract.getCurrentEpoch();
(uint256 _startingEpochFirstBlock, , uint256 _startingStartTimestamp, ) = epochManagerContract
.getCurrentEpoch();

_travelAndProcess_N_L2Epoch(numberOfEpochsToTravel);

@@ -1078,97 +1068,145 @@ contract EpochManagerTest_getEpochByNumber_L2 is EpochManagerTest_L2 {
}
}

// contract EpochManagerTest_getEpochNumberOfBlock is EpochManagerTest {
// function test_ShouldRetreiveTheCorrectBlockNumberOfTheEpoch() public {
// initializeEpochManagerSystem();
// assertEq(epochManagerContract.getEpochNumberOfBlock(firstEpochBlock), firstEpochNumber);
// }

// function test_Reverts_WhenL1() public {
// vm.expectRevert("Epoch system not initialized");
// epochManagerContract.getEpochNumberOfBlock(firstEpochBlock);
// }
// }

// contract EpochManagerTest_getEpochByBlockNumber is EpochManagerTest {
// function test_ShouldRetreiveTheCorrectEpochInfoOfGivenBlock() public {
// initializeEpochManagerSystem();

// _travelAndProcess_N_L2Epoch(2);
contract EpochManagerTest_getEpochNumberOfBlock is EpochManagerTest {
function test_Reverts_WhenL1() public {
vm.expectRevert("Epoch system not initialized");
epochManagerContract.getEpochNumberOfBlock(75);
}
}
contract EpochManagerTest_getEpochNumberOfBlock_L2 is EpochManagerTest_L2 {
function setUp() public override(EpochManagerTest_L2) {
super.setUp();
}

// (uint256 _firstBlock, uint256 _lastBlock, , ) = epochManagerContract.getEpochByBlockNumber(
// firstEpochBlock + (3 * L2_BLOCK_IN_EPOCH)
// );
// assertEq(_firstBlock, firstEpochBlock + 1 + (2 * L2_BLOCK_IN_EPOCH));
// assertEq(_lastBlock, firstEpochBlock + 1 + (3 * L2_BLOCK_IN_EPOCH) - 1);
// }
function test_ShouldRetreiveTheCorrectBlockNumberOfTheEpoch() public {
assertEq(
epochManagerContract.getEpochNumberOfBlock(epochManagerEnabler.lastKnownFirstBlockOfEpoch()),
firstEpochNumber
);
}
}

// function test_Reverts_WhenL1() public {
// vm.expectRevert("Epoch system not initialized");
// epochManagerContract.getEpochNumberOfBlock(firstEpochBlock);
// }
// }
contract EpochManagerTest_getEpochByBlockNumber is EpochManagerTest {
function test_Reverts_WhenL1() public {
vm.expectRevert("Epoch system not initialized");
epochManagerContract.getEpochNumberOfBlock(1000);
}
}
contract EpochManagerTest_getEpochByBlockNumber_L2 is EpochManagerTest_L2 {
function setUp() public override(EpochManagerTest_L2) {
super.setUp();
initializeEpochManagerSystem();
_travelAndProcess_N_L2Epoch(2);
}
function test_ShouldRetreiveTheCorrectEpochInfoOfGivenBlock() public {
(uint256 _firstBlock, uint256 _lastBlock, , ) = epochManagerContract.getEpochByBlockNumber(
epochManagerEnabler.lastKnownFirstBlockOfEpoch() + (3 * L2_BLOCK_IN_EPOCH)
);
assertEq(
_firstBlock,
epochManagerEnabler.lastKnownFirstBlockOfEpoch() + 1 + (2 * L2_BLOCK_IN_EPOCH)
);
assertEq(
_lastBlock,
epochManagerEnabler.lastKnownFirstBlockOfEpoch() + 1 + (3 * L2_BLOCK_IN_EPOCH) - 1
);
}
}

// contract EpochManagerTest_numberOfElectedInCurrentSet is EpochManagerTest {
// function test_ShouldRetreiveTheNumberOfElected() public {
// initializeEpochManagerSystem();
// assertEq(epochManagerContract.numberOfElectedInCurrentSet(), 2);
// }
contract EpochManagerTest_numberOfElectedInCurrentSet is EpochManagerTest {
function test_Reverts_WhenL1() public {
vm.expectRevert("Epoch system not initialized");
epochManagerContract.numberOfElectedInCurrentSet();
}
}
contract EpochManagerTest_numberOfElectedInCurrentSet_L2 is EpochManagerTest_L2 {
function setUp() public override(EpochManagerTest_L2) {
super.setUp();
initializeEpochManagerSystem();
}
function test_ShouldRetreiveTheNumberOfElected() public {
assertEq(
epochManagerContract.numberOfElectedInCurrentSet(),
epochManagerEnabler.getlastKnownElectedAccounts().length
);
}
}

// function test_Reverts_WhenL1() public {
// vm.expectRevert("Epoch system not initialized");
// epochManagerContract.numberOfElectedInCurrentSet();
// }
// }
contract EpochManagerTest_getElectedAccounts is EpochManagerTest {
function test_Reverts_WhenL1() public {
vm.expectRevert("Epoch system not initialized");
epochManagerContract.getElectedAccounts();
}
}

// contract EpochManagerTest_getElectedAccounts is EpochManagerTest {
// function test_ShouldRetreiveThelistOfElectedAccounts() public {
// initializeEpochManagerSystem();
// assertEq(epochManagerContract.getElectedAccounts(), firstElected);
// }
contract EpochManagerTest_getElectedAccounts_L2 is EpochManagerTest_L2 {
function setUp() public override(EpochManagerTest_L2) {
super.setUp();
initializeEpochManagerSystem();
}
function test_ShouldRetreiveThelistOfElectedAccounts() public {
assertEq(
epochManagerContract.getElectedAccounts(),
epochManagerEnabler.getlastKnownElectedAccounts()
);
}
}

// function test_Reverts_WhenL1() public {
// vm.expectRevert("Epoch system not initialized");
// epochManagerContract.getElectedAccounts();
// }
// }
contract EpochManagerTest_getElectedAccountByIndex is EpochManagerTest {
function test_Reverts_WhenL1() public {
vm.expectRevert("Epoch system not initialized");
epochManagerContract.getElectedAccountByIndex(0);
}
}
contract EpochManagerTest_getElectedAccountByIndex_L2 is EpochManagerTest_L2 {
function setUp() public override(EpochManagerTest_L2) {
super.setUp();
initializeEpochManagerSystem();
}
function test_ShouldRetreiveThecorrectValidator() public {
assertEq(epochManagerContract.getElectedAccountByIndex(0), validator1);
}
}

// contract EpochManagerTest_getElectedAccountByIndex is EpochManagerTest {
// function test_ShouldRetreiveThecorrectValidator() public {
// initializeEpochManagerSystem();
// assertEq(epochManagerContract.getElectedAccountByIndex(0), validator1);
// }
contract EpochManagerTest_getElectedSigners is EpochManagerTest {
function test_Reverts_WhenL1() public {
vm.expectRevert("Epoch system not initialized");
epochManagerContract.getElectedSigners();
}
}
contract EpochManagerTest_getElectedSigners_L2 is EpochManagerTest_L2 {
function setUp() public override(EpochManagerTest_L2) {
super.setUp();
initializeEpochManagerSystem();
}

// function test_Reverts_WhenL1() public {
// vm.expectRevert("Epoch system not initialized");
// epochManagerContract.getElectedAccountByIndex(0);
// }
// }
// contract EpochManagerTest_getElectedSigners is EpochManagerTest {
// function test_ShouldRetreiveTheElectedSigners() public {
// initializeEpochManagerSystem();
// address[] memory electedSigners = new address[](firstElected.length);
// electedSigners[0] = accountss.getValidatorSigner(firstElected[0]);
// electedSigners[1] = accountss.getValidatorSigner(firstElected[1]);
// assertEq(epochManagerContract.getElectedSigners(), electedSigners);
// }
function test_ShouldRetreiveTheElectedSigners() public {
address[] memory knownElectedAccounts = epochManagerEnabler.getlastKnownElectedAccounts();
address[] memory electedSigners = new address[](knownElectedAccounts.length);
for (uint256 i = 0; i < knownElectedAccounts.length; i++) {
electedSigners[i] = accountsContract.getValidatorSigner(knownElectedAccounts[i]);
}
assertEq(epochManagerContract.getElectedSigners(), electedSigners);
}
}

// function test_Reverts_WhenL1() public {
// vm.expectRevert("Epoch system not initialized");
// epochManagerContract.getElectedSigners();
// }
// }
// contract EpochManagerTest_getElectedSignerByIndex is EpochManagerTest {
// function test_ShouldRetreiveThecorrectElectedSigner() public {
// initializeEpochManagerSystem();
// address[] memory electedSigners = new address[](firstElected.length);

// electedSigners[1] = accountss.getValidatorSigner(firstElected[1]);
// assertEq(epochManagerContract.getElectedSignerByIndex(1), electedSigners[1]);
// }
contract EpochManagerTest_getElectedSignerByIndex is EpochManagerTest {
function test_Reverts_WhenL1() public {
vm.expectRevert("Epoch system not initialized");
epochManagerContract.getElectedSignerByIndex(1);
}
}
contract EpochManagerTest_getElectedSignerByIndex_L2 is EpochManagerTest_L2 {
function setUp() public override(EpochManagerTest_L2) {
super.setUp();
initializeEpochManagerSystem();
}
function test_ShouldRetreiveThecorrectElectedSigner() public {
address[] memory knownElectedAccounts = epochManagerEnabler.getlastKnownElectedAccounts();
address[] memory electedSigners = new address[](knownElectedAccounts.length);

// function test_Reverts_WhenL1() public {
// vm.expectRevert("Epoch system not initialized");
// epochManagerContract.getElectedSignerByIndex(1);
// }
// }
electedSigners[1] = accountsContract.getValidatorSigner(knownElectedAccounts[1]);
assertEq(epochManagerContract.getElectedSignerByIndex(1), electedSigners[1]);
}
}
Loading