-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
startNextEpochProcess unit & integration test (#11191)
* unit test with mocks * ++ integration tests * clean up * -- logging * removed duplicate interface * using `MockCeloToken` to get test to pass. Fails when it hits a precompile in `EpochRewards.sol` * removed endEpochTimestamp * moved IEpochManager to 0.5 folder * added L2 conditions for EpochRewards functions using precompiles Still missing tests * renamed EpochManagerInitializer due to name conflict * ++ more unit test * setup anvil migration fix name conflict * compiles * ++ require fund in unreleased treasury * Updated regex * ++ registry 0.8 for testing only * clean up * ++ unit test * initial integration test using L1 devchain * ++ comment * -- forge based integration test * ++ to const * happy linter * update contract name * ++ PR feedback * ++ checks * updated carbon address * proxy stableToken mint call via Validators contract * -- duplicate imports * removed registry08. replaced with vm call * PR feedback * -- coment * passing unit tests * clean up * ++ mintStable test * -- TODO; compiles test when filtering * PR feedback * updated migration script to add more validators * passing integration test * removed test for zero amount * yarn build fix * clean up comments && TODO * revert change as out of scope
- Loading branch information
Showing
40 changed files
with
1,041 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
packages/protocol/contracts-0.8/common/interfaces/ICeloToken.sol
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
packages/protocol/contracts-0.8/common/interfaces/IEpochManagerEnablerInitializer.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
pragma solidity >=0.5.13 <0.9.0; | ||
|
||
interface IEpochManagerEnablerInitializer { | ||
function initialize(address registryAddress) external; | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/protocol/contracts-0.8/common/interfaces/IEpochManagerInitializer.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
pragma solidity >=0.5.13 <0.9.0; | ||
|
||
interface IEpochManagerInitializer { | ||
function initialize( | ||
address registryAddress, | ||
uint256 newEpochDuration, | ||
address _carbonOffsettingPartner, | ||
address _epochManagerEnabler | ||
) external; | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/protocol/contracts-0.8/common/interfaces/IScoreManagerInitializer.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
pragma solidity >=0.5.13 <0.9.0; | ||
|
||
interface IScoreManagerInitializer { | ||
function initialize() external; | ||
} |
60 changes: 60 additions & 0 deletions
60
packages/protocol/contracts-0.8/common/test/MockCeloToken.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
pragma solidity >=0.8.0 <0.9.0; | ||
// solhint-disable no-unused-vars | ||
|
||
/** | ||
* @title A mock StableToken for testing. This contract can be deprecated once GoldToken gets migrated to 0.8 | ||
*/ | ||
contract MockCeloToken08 { | ||
uint256 public totalSupply_; | ||
uint8 public constant decimals = 18; | ||
mapping(address => uint256) balances; | ||
|
||
uint256 constant L1_MINTED_CELO_SUPPLY = 692702432463315819704447326; // as of May 15 2024 | ||
|
||
uint256 constant CELO_SUPPLY_CAP = 1000000000 ether; // 1 billion Celo | ||
uint256 constant GENESIS_CELO_SUPPLY = 600000000 ether; // 600 million Celo | ||
|
||
uint256 constant FIFTEEN_YEAR_LINEAR_REWARD = (CELO_SUPPLY_CAP - GENESIS_CELO_SUPPLY) / 2; // 200 million Celo | ||
|
||
uint256 constant FIFTEEN_YEAR_CELO_SUPPLY = GENESIS_CELO_SUPPLY + FIFTEEN_YEAR_LINEAR_REWARD; // 800 million Celo (includes GENESIS_CELO_SUPPLY) | ||
|
||
uint256 constant MAX_L2_DISTRIBUTION = FIFTEEN_YEAR_CELO_SUPPLY - L1_MINTED_CELO_SUPPLY; // 107.2 million Celo | ||
|
||
uint256 constant L2_INITIAL_STASH_BALANCE = FIFTEEN_YEAR_LINEAR_REWARD + MAX_L2_DISTRIBUTION; // leftover from L1 target supply plus the 2nd 15 year term. | ||
|
||
function setTotalSupply(uint256 value) external { | ||
totalSupply_ = value; | ||
} | ||
|
||
function transfer(address to, uint256 amount) external returns (bool) { | ||
return _transfer(msg.sender, to, amount); | ||
} | ||
|
||
function transferFrom(address from, address to, uint256 amount) external returns (bool) { | ||
return _transfer(from, to, amount); | ||
} | ||
|
||
function _transfer(address from, address to, uint256 amount) internal returns (bool) { | ||
if (balances[from] < amount) { | ||
return false; | ||
} | ||
balances[from] -= amount; | ||
balances[to] += amount; | ||
return true; | ||
} | ||
|
||
function setBalanceOf(address a, uint256 value) external { | ||
balances[a] = value; | ||
} | ||
|
||
function balanceOf(address a) public view returns (uint256) { | ||
return balances[a]; | ||
} | ||
|
||
function totalSupply() public view returns (uint256) { | ||
return totalSupply_; | ||
} | ||
function allocatedSupply() public view returns (uint256) { | ||
return CELO_SUPPLY_CAP - L2_INITIAL_STASH_BALANCE; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/protocol/contracts-0.8/common/test/MockCeloUnreleasedTreasure.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pragma solidity >=0.8.0 <0.9.0; | ||
// solhint-disable no-unused-vars | ||
|
||
import "../../../contracts/common/interfaces/ICeloUnreleasedTreasure.sol"; | ||
import "../UsingRegistry.sol"; | ||
|
||
/** | ||
* @title A mock CeloUnreleasedTreasure for testing. | ||
*/ | ||
contract MockCeloUnreleasedTreasure is ICeloUnreleasedTreasure, UsingRegistry { | ||
function release(address to, uint256 amount) external { | ||
require(address(this).balance >= amount, "Insufficient balance."); | ||
require(getCeloToken().transfer(to, amount), "CELO transfer failed."); | ||
} | ||
} |
Oops, something went wrong.