Skip to content

Commit

Permalink
fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Dec 7, 2023
1 parent c146c42 commit 8ccd11c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions test/SlashIndicator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ contract SlashIndicatorTest is Deployer {
address public validator0;

function setUp() public {
burnRatio = bscValidatorSet.isSystemRewardIncluded() ? bscValidatorSet.burnRatio() : 938; // 15/16*10% is 9.375%
burnRatio =
bscValidatorSet.isSystemRewardIncluded() ? bscValidatorSet.burnRatio() : bscValidatorSet.INIT_BURN_RATIO();
burnRatioScale = bscValidatorSet.BURN_RATIO_SCALE();

systemRewardRatio = bscValidatorSet.isSystemRewardIncluded() ? bscValidatorSet.systemRewardRatio() : 625; // 1/16
systemRewardRatio = bscValidatorSet.isSystemRewardIncluded()
? bscValidatorSet.systemRewardRatio()
: bscValidatorSet.INIT_SYSTEM_REWARD_RATIO();
systemRewardRatioScale = bscValidatorSet.SYSTEM_REWARD_RATIO_SCALE();

address[] memory validators = bscValidatorSet.getValidators();
Expand Down
11 changes: 7 additions & 4 deletions test/ValidatorSet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ contract ValidatorSetTest is Deployer {
_updateParamByGovHub(key, valueBytes, address(systemReward));
assertTrue(systemReward.isOperator(address(bscValidatorSet)));

burnRatio = bscValidatorSet.isSystemRewardIncluded() ? bscValidatorSet.burnRatio() : 938; // 15/16*10% is 9.375%
burnRatio =
bscValidatorSet.isSystemRewardIncluded() ? bscValidatorSet.burnRatio() : bscValidatorSet.INIT_BURN_RATIO();
burnRatioScale = bscValidatorSet.BURN_RATIO_SCALE();
systemRewardRatio = bscValidatorSet.isSystemRewardIncluded() ? bscValidatorSet.systemRewardRatio() : 625; // 1/16
systemRewardRatio = bscValidatorSet.isSystemRewardIncluded()
? bscValidatorSet.systemRewardRatio()
: bscValidatorSet.INIT_SYSTEM_REWARD_RATIO();
systemRewardRatioScale = bscValidatorSet.SYSTEM_REWARD_RATIO_SCALE();
totalInComing = bscValidatorSet.totalInComing();
maxNumOfWorkingCandidates = bscValidatorSet.maxNumOfWorkingCandidates();
Expand Down Expand Up @@ -592,8 +595,8 @@ contract ValidatorSetTest is Deployer {
bscValidatorSet.distributeFinalityReward(addrs, weights);
assertEq(address(systemReward).balance, ceil);

// cannot exceed MAX_SYSTEM_REWARD_BALANCE
uint256 cap = systemReward.MAX_REWARDS();
// cannot exceed MAX_REWARDS_FOR_FINALITY
uint256 cap = systemReward.MAX_REWARDS_FOR_FINALITY();
vm.deal(address(systemReward), ceil + cap * 2);
vm.roll(block.number + 1);

Expand Down
2 changes: 2 additions & 0 deletions test/utils/interface/ISystemReward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface SystemReward {
function INCENTIVIZE_ADDR() external view returns (address);
function LIGHT_CLIENT_ADDR() external view returns (address);
function MAX_REWARDS() external view returns (uint256);
function MAX_REWARDS_FOR_FINALITY() external view returns (uint256);
function RELAYERHUB_CONTRACT_ADDR() external view returns (address);
function SLASH_CHANNELID() external view returns (uint8);
function SLASH_CONTRACT_ADDR() external view returns (address);
Expand All @@ -38,6 +39,7 @@ interface SystemReward {
function alreadyInit() external view returns (bool);
function bscChainID() external view returns (uint16);
function claimRewards(address payable to, uint256 amount) external returns (uint256);
function claimRewardsforFinality(address payable to, uint256 amount) external returns (uint256);
function isOperator(address addr) external view returns (bool);
function numOperator() external view returns (uint256);
function updateParam(string memory key, bytes memory value) external;
Expand Down
1 change: 1 addition & 0 deletions test/utils/interface/ITokenHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ interface TokenHub {
function cancelTokenRecoverLock(bytes32 tokenSymbol, address attacker) external;
function cancelTransferIn(address tokenAddress, address attacker) external;
function claimRewards(address payable to, uint256 amount) external returns (uint256);
function claimRewardsforFinality(address payable, uint256) external returns (uint256);
function getBep2SymbolByContractAddr(address contractAddr) external view returns (bytes32);
function getBoundBep2Symbol(address contractAddr) external view returns (string memory);
function getBoundContract(string memory bep2Symbol) external view returns (address);
Expand Down

0 comments on commit 8ccd11c

Please sign in to comment.