Skip to content

Commit

Permalink
test: reuse deployment scripts in test
Browse files Browse the repository at this point in the history
  • Loading branch information
huyhuynh3103 committed Jan 18, 2024
1 parent e421099 commit 9498c45
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 2,400 deletions.
1,527 changes: 0 additions & 1,527 deletions logs/debug.ansi

This file was deleted.

26 changes: 4 additions & 22 deletions script/GeneralConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ contract GeneralConfig is BaseGeneralConfig, Utils {

// ronin bridge contracts
setAddress(DefaultNetwork.Local.key(), Contract.RoninGatewayV3.key(), vm.computeCreateAddress(deployer, 4));
setAddress(DefaultNetwork.Local.key(), Contract.RoninBridgeManager.key(), vm.computeCreateAddress(deployer, 5));
setAddress(DefaultNetwork.Local.key(), Contract.BridgeTracking.key(), vm.computeCreateAddress(deployer, 7));
setAddress(DefaultNetwork.Local.key(), Contract.BridgeSlash.key(), vm.computeCreateAddress(deployer, 9));
setAddress(DefaultNetwork.Local.key(), Contract.BridgeReward.key(), vm.computeCreateAddress(deployer, 11));
setAddress(DefaultNetwork.Local.key(), Contract.BridgeTracking.key(), vm.computeCreateAddress(deployer, 6));
setAddress(DefaultNetwork.Local.key(), Contract.BridgeSlash.key(), vm.computeCreateAddress(deployer, 8));
setAddress(DefaultNetwork.Local.key(), Contract.BridgeReward.key(), vm.computeCreateAddress(deployer, 10));
setAddress(DefaultNetwork.Local.key(), Contract.RoninBridgeManager.key(), vm.computeCreateAddress(deployer, 11));

//mainchain bridge contracts
setAddress(DefaultNetwork.Local.key(), Contract.MainchainGatewayV3.key(), vm.computeCreateAddress(deployer, 13));
Expand All @@ -75,24 +75,6 @@ contract GeneralConfig is BaseGeneralConfig, Utils {
setAddress(DefaultNetwork.Local.key(), Contract.AXS.key(), vm.computeCreateAddress(deployer, 16));
setAddress(DefaultNetwork.Local.key(), Contract.SLP.key(), vm.computeCreateAddress(deployer, 17));
setAddress(DefaultNetwork.Local.key(), Contract.USDC.key(), vm.computeCreateAddress(deployer, 18));

console.log("Deployer", deployer);
console.log(" > roninGateway", getAddress(DefaultNetwork.Local.key(), Contract.RoninGatewayV3.key()));
console.log(" > mainchainGateway", getAddress(DefaultNetwork.Local.key(), Contract.MainchainGatewayV3.key()));
console.log(" > bridgeTrackingContract", getAddress(DefaultNetwork.Local.key(), Contract.BridgeTracking.key()));
console.log(" > bridgeSlashContract", getAddress(DefaultNetwork.Local.key(), Contract.BridgeSlash.key()));
console.log(" > bridgeRewardContract", getAddress(DefaultNetwork.Local.key(), Contract.BridgeReward.key()));
console.log(
" > roninBridgeManagerContract", getAddress(DefaultNetwork.Local.key(), Contract.RoninBridgeManager.key())
);
console.log(
" > mainchainBridgeManagerContract",
getAddress(DefaultNetwork.Local.key(), Contract.MainchainBridgeManager.key())
);
console.log(" > WETH", getAddress(DefaultNetwork.Local.key(), Contract.WETH.key()));
console.log(" > AXS", getAddress(DefaultNetwork.Local.key(), Contract.AXS.key()));
console.log(" > SLP", getAddress(DefaultNetwork.Local.key(), Contract.SLP.key()));
console.log(" > USDC", getAddress(DefaultNetwork.Local.key(), Contract.USDC.key()));
}
}

Expand Down
13 changes: 6 additions & 7 deletions script/Migration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,14 @@ contract Migration is BaseMigration, Utils {
options[0] = GlobalProposal.TargetOption.GatewayContract;
targets[0] = loadContract(Contract.MainchainGatewayV3.key());

param.mainchainBridgeManager.num = 70;
param.mainchainBridgeManager.denom = 100;
param.mainchainBridgeManager.roninChainId = block.chainid;
param.roninBridgeManager.expiryDuration = 60 * 60 * 24 * 14; // 14 days
param.mainchainBridgeManager.num = 2;
param.mainchainBridgeManager.denom = 4;
param.mainchainBridgeManager.roninChainId = 0;
param.mainchainBridgeManager.bridgeContract = loadContract(Contract.MainchainGatewayV3.key());
param.mainchainBridgeManager.callbackRegisters = getEmptyAddressArray();
param.mainchainBridgeManager.bridgeOperators = getEmptyAddressArray();
param.mainchainBridgeManager.governors = getEmptyAddressArray();
param.mainchainBridgeManager.voteWeights = getEmptyUint96Array();
param.mainchainBridgeManager.bridgeOperators = operatorAddrs;
param.mainchainBridgeManager.governors = governorAddrs;
param.mainchainBridgeManager.voteWeights = voteWeights;
param.mainchainBridgeManager.targetOptions = options;
param.mainchainBridgeManager.targets = targets;

Expand Down
1 change: 0 additions & 1 deletion script/contracts/MainchainBridgeManagerDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ contract MainchainBridgeManagerDeploy is Migration {
param.num,
param.denom,
param.roninChainId,
param.expiryDuration,
param.bridgeContract,
param.callbackRegisters,
param.bridgeOperators,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { AXSDeploy } from "@ronin/script/contracts/token/AXSDeploy.s.sol";
import { SLPDeploy } from "@ronin/script/contracts/token/SLPDeploy.s.sol";
import { USDCDeploy } from "@ronin/script/contracts/token/USDCDeploy.s.sol";

contract Base_Integration is Base_Test {
contract BaseIntegration_Test is Base_Test {
ISharedArgument.SharedParameter _param;

RoninBridgeManager _roninBridgeManager;
Expand All @@ -45,10 +45,10 @@ contract Base_Integration is Base_Test {

function setUp() public virtual {
_roninGatewayV3 = new RoninGatewayV3Deploy().run();
_roninBridgeManager = new RoninBridgeManagerDeploy().run();
_bridgeTracking = new BridgeTrackingDeploy().run();
_bridgeSlash = new BridgeSlashDeploy().run();
_bridgeReward = new BridgeRewardDeploy().run();
_roninBridgeManager = new RoninBridgeManagerDeploy().run();

_mainchainGatewayV3 = new MainchainGatewayV3Deploy().run();
_mainchainBridgeManager = new MainchainBridgeManagerDeploy().run();
Expand All @@ -60,6 +60,4 @@ contract Base_Integration is Base_Test {

_param = ISharedArgument(LibSharedAddress.CONFIG).sharedArguments();
}

function test_() public { }
}
32 changes: 0 additions & 32 deletions test/bridge/integration/bridge-manager/BridgeManagerInterface.sol

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "../BridgeManager_IntegrationTest.t.sol";
import { GlobalProposal } from "@ronin/contracts/libraries/GlobalProposal.sol";
import { ContractType } from "@ronin/contracts/utils/ContractType.sol";
import "../../BaseIntegration.t.sol";

contract SetConfig_MainchainManager_Test is Bridge_Integration_Test {
contract SetConfig_MainchainManager_Test is BaseIntegration_Test {
function setUp() public virtual override {
super.setUp();
}
Expand All @@ -16,9 +18,7 @@ contract SetConfig_MainchainManager_Test is Bridge_Integration_Test {
function test_configBridgeOperatorsCorrectly() external {
address[] memory bridgeOperators = _mainchainBridgeManager.getBridgeOperators();

for (uint256 i; i < bridgeOperators.length; i++) {
assertEq(bridgeOperators[i], _operators[i].addr);
}
assertEq(bridgeOperators, _param.mainchainBridgeManager.bridgeOperators);
}

function test_configTargetsCorrectly() external {
Expand All @@ -33,8 +33,8 @@ contract SetConfig_MainchainManager_Test is Bridge_Integration_Test {

assertEq(results[0], address(_mainchainBridgeManager));
assertEq(results[1], address(_mainchainGatewayV3));
assertEq(results[2], address(DEFAULT_ADDRESS));
assertEq(results[3], address(DEFAULT_ADDRESS));
assertEq(results[4], address(DEFAULT_ADDRESS));
assertEq(results[2], address(address(0)));
assertEq(results[3], address(address(0)));
assertEq(results[4], address(address(0)));
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "../BridgeManager_IntegrationTest.t.sol";
import { GlobalProposal } from "@ronin/contracts/libraries/GlobalProposal.sol";
import { ContractType } from "@ronin/contracts/utils/ContractType.sol";
import "../../BaseIntegration.t.sol";

contract SetConfig_RoninBridgeManager_Test is Bridge_Integration_Test {
contract SetConfig_RoninBridgeManager_Test is BaseIntegration_Test {
function setUp() public virtual override {
super.setUp();
}

function test_configBridgeContractCorrectly() external {
address bridgeContract = _roninBridgeManager.getContract(ContractType.BRIDGE);
assertEq(bridgeContract, address(_roninGatewayV3Contract));
assertEq(bridgeContract, address(_roninGatewayV3));
}

function test_configBridgeOperatorsCorrectly() external {
address[] memory bridgeOperators = _roninBridgeManager.getBridgeOperators();

for (uint256 i; i < bridgeOperators.length; i++) {
assertEq(bridgeOperators[i], _operators[i].addr);
}
assertEq(bridgeOperators, _param.roninBridgeManager.bridgeOperators);
}

function test_configTargetsCorrectly() external {
Expand All @@ -32,7 +32,7 @@ contract SetConfig_RoninBridgeManager_Test is Bridge_Integration_Test {
address[] memory results = _roninBridgeManager.resolveTargets(targets);

assertEq(results[0], address(_roninBridgeManager));
assertEq(results[1], address(_roninGatewayV3Contract));
assertEq(results[1], address(_roninGatewayV3));
assertEq(results[2], address(_bridgeSlash));
assertEq(results[3], address(_bridgeReward));
assertEq(results[4], address(_bridgeTracking));
Expand Down
88 changes: 0 additions & 88 deletions test/init-test/DefaultTestConfig.sol

This file was deleted.

Loading

0 comments on commit 9498c45

Please sign in to comment.