Skip to content

Commit

Permalink
Merge pull request bnb-chain#551 from Pythonberg1997/develop
Browse files Browse the repository at this point in the history
chore: fix typo and unit tests
  • Loading branch information
pythonberg1997 authored Apr 8, 2024
2 parents af4c147 + c037164 commit 4826b48
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 41 deletions.
8 changes: 4 additions & 4 deletions scripts/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def generate_validator_set(init_validatorset_bytes, init_burn_ratio, epoch):

if network == "dev":
insert(
contract, r"for \(uint i; i<validatorSetPkg\.validatorSet\.length; \+\+i\)",
contract, r"for \(uint256 i; i < validatorSetPkg\.validatorSet\.length; \+\+i\)",
"\t\tValidatorExtra memory validatorExtra;"
)
insert(
Expand All @@ -267,8 +267,8 @@ def generate_validator_set(init_validatorset_bytes, init_burn_ratio, epoch):
)
replace(
contract,
r"handleSynPackage\(uint8, bytes calldata msgBytes\) onlyInit onlyCrossChainContract initValidatorExtraSet",
"handleSynPackage(uint8, bytes calldata msgBytes) onlyInit initValidatorExtraSet"
r"handleSynPackage\(\s*uint8,\s*bytes calldata msgBytes\s*\) external override onlyInit onlyCrossChainContract initValidatorExtraSet",
"handleSynPackage(uint8, bytes calldata msgBytes) external override onlyInit initValidatorExtraSet"
)


Expand All @@ -280,7 +280,7 @@ def generate_gov_hub():

if network == "dev":
replace(
contract, r"handleSynPackage\(uint8, bytes calldata msgBytes\) external onlyCrossChainContract override",
contract, r"handleSynPackage\(\s*uint8,\s*bytes calldata msgBytes\s*\) external override onlyCrossChainContract",
"handleSynPackage(uint8, bytes calldata msgBytes) external override"
)

Expand Down
38 changes: 18 additions & 20 deletions test/TokenHub.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ pragma solidity ^0.8.10;

import "./utils/Deployer.sol";

import "./utils/interface/ITestToken.sol";
import "./utils/test_token/ABCToken.sol";
import "./utils/test_token/DEFToken.sol";
import "./utils/test_token/MaliciousToken.sol";
import "./utils/test_token/MiniToken.sol";
import "./utils/test_token/XYZToken.sol";

contract TokenHubTest is Deployer {
Expand All @@ -16,34 +19,29 @@ contract TokenHubTest is Deployer {
event transferOutSuccess(address bep20Addr, address senderAddr, uint256 amount, uint256 relayFee);
event refundSuccess(address bep20Addr, address refundAddr, uint256 amount, uint32 status);

ITestToken public abcToken;
ITestToken public defToken;
ABCToken public abcToken;
DEFToken public defToken;
XYZToken public xyzToken;
ITestToken public maliciousToken;
ITestToken public miniToken;
MaliciousToken public maliciousToken;
MiniToken public miniToken;

receive() external payable { }

function setUp() public {
address abcAddr = deployCode("ABCToken.sol");
abcToken = ITestToken(abcAddr);
vm.label(abcAddr, "ABCToken");
abcToken = new ABCToken();
vm.label(address(abcToken), "ABCToken");

address defAddr = deployCode("DEFToken.sol");
defToken = ITestToken(defAddr);
vm.label(defAddr, "DEFToken");
defToken = new DEFToken();
vm.label(address(defToken), "DEFToken");

address xyzAddr = deployCode("XYZToken.sol");
xyzToken = XYZToken(xyzAddr);
vm.label(xyzAddr, "XYZToken");
xyzToken = new XYZToken();
vm.label(address(xyzToken), "XYZToken");

address maliciousAddr = deployCode("MaliciousToken.sol");
maliciousToken = ITestToken(maliciousAddr);
vm.label(maliciousAddr, "MaliciousToken");
maliciousToken = new MaliciousToken();
vm.label(address(maliciousToken), "MaliciousToken");

address miniAddr = deployCode("MiniToken.sol");
miniToken = ITestToken(miniAddr);
vm.label(miniAddr, "MiniToken");
miniToken = new MiniToken();
vm.label(address(miniToken), "MiniToken");
}

function testBindFailed() public {
Expand Down
34 changes: 17 additions & 17 deletions test/utils/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,39 +121,39 @@ contract Deployer is Test {
vm.label(address(tokenRecoverPortal), "TokenRecoverPortal");

// set the latest code
bytes memory deployedCode = vm.getDeployedCode("BSCValidatorSet.sol");
bytes memory deployedCode = vm.getDeployedCode("BSCValidatorSet.sol:BSCValidatorSet");
vm.etch(VALIDATOR_CONTRACT_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("SlashIndicator.sol");
deployedCode = vm.getDeployedCode("SlashIndicator.sol:SlashIndicator");
vm.etch(SLASH_CONTRACT_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("SystemReward.sol");
deployedCode = vm.getDeployedCode("SystemReward.sol:SystemReward");
vm.etch(SYSTEM_REWARD_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("TendermintLightClient.sol");
deployedCode = vm.getDeployedCode("TendermintLightClient.sol:TendermintLightClient");
vm.etch(LIGHT_CLIENT_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("TokenHub.sol");
deployedCode = vm.getDeployedCode("TokenHub.sol:TokenHub");
vm.etch(TOKEN_HUB_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("RelayerIncentivize.sol");
deployedCode = vm.getDeployedCode("RelayerIncentivize.sol:RelayerIncentivize");
vm.etch(INCENTIVIZE_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("RelayerHub.sol");
deployedCode = vm.getDeployedCode("RelayerHub.sol:RelayerHub");
vm.etch(RELAYERHUB_CONTRACT_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("GovHub.sol");
deployedCode = vm.getDeployedCode("GovHub.sol:GovHub");
vm.etch(GOV_HUB_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("TokenManager.sol");
deployedCode = vm.getDeployedCode("TokenManager.sol:TokenManager");
vm.etch(TOKEN_MANAGER_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("CrossChain.sol");
deployedCode = vm.getDeployedCode("CrossChain.sol:CrossChain");
vm.etch(CROSS_CHAIN_CONTRACT_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("Staking.sol");
deployedCode = vm.getDeployedCode("Staking.sol:Staking");
vm.etch(STAKING_CONTRACT_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("StakeHub.sol");
deployedCode = vm.getDeployedCode("StakeHub.sol:StakeHub");
vm.etch(STAKE_HUB_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("StakeCredit.sol");
deployedCode = vm.getDeployedCode("StakeCredit.sol:StakeCredit");
vm.etch(STAKE_CREDIT_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("BSCGovernor.sol");
deployedCode = vm.getDeployedCode("BSCGovernor.sol:BSCGovernor");
vm.etch(GOVERNOR_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("GovToken.sol");
deployedCode = vm.getDeployedCode("GovToken.sol:GovToken");
vm.etch(GOV_TOKEN_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("BSCTimelock.sol");
deployedCode = vm.getDeployedCode("BSCTimelock.sol:BSCTimelock");
vm.etch(TIMELOCK_ADDR, deployedCode);
deployedCode = vm.getDeployedCode("TokenRecoverPortal.sol");
deployedCode = vm.getDeployedCode("TokenRecoverPortal.sol:TokenRecoverPortal");
vm.etch(TOKEN_RECOVER_PORTAL_ADDR, deployedCode);

relayer = payable(0xb005741528b86F5952469d80A8614591E3c5B632); // whitelabel relayer
Expand Down

0 comments on commit 4826b48

Please sign in to comment.