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

fork tests on other chains + fork test bug fix #556

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
11 changes: 8 additions & 3 deletions packages/contracts-ops/contracts/test/Reboot.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {NomadTest} from "@nomad-xyz/contracts-core/contracts/test/utils/NomadTes

contract RebootTest is RebootLogic, NomadTest {
string remote;
string constant _domain = "ethereum";
string constant testDomain = "ethereum";

function setUpReboot(string memory testName) public {
// ALL
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could get RPC from config instead of .env, that would make it easier to switch between chains quickly, but the config RPC situation is grim because those are all public endpoints that are usually quite frail

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionally, we could remove the pinned block number in order to make it more seamlessly compatible with all chains, but then the tests wouldn't cache the block which would make them even slower

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't get RPC from config, we don't want to keep good RPCs in those

Expand All @@ -25,10 +25,15 @@ contract RebootTest is RebootLogic, NomadTest {
vm.writeFile(_path, vm.readFile("./actions/config.json"));
__Config_initialize(_configName);
// init fresh callbatch
__CallBatch_initialize(_domain, getDomainNumber(_domain), "", true);
__CallBatch_initialize(
testDomain,
getDomainNumber(testDomain),
"",
true
);
// call base setup
super.setUp();
// set fake updater for ethereum & 1 remote chain
// set fake updater for remote chain replica
// before updater rotation, so it will be rotated on-chain
vm.writeJson(
vm.toString(updaterAddr),
Expand Down
40 changes: 23 additions & 17 deletions packages/contracts-ops/contracts/test/RebootBridgeRouter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@ contract BridgeRouterRebootTest is RebootTest, BridgeRouterTest {
address bridgeRouterHarnessImpl;
address tokenRegistryHarnessImpl;

string constant ethereum = "ethereum";

function setUp() public override(BridgeRouterBaseTest, NomadTest) {
setUpReboot("bridgeRouter");
// load proxies
tokenRegistry = TokenRegistryHarness(
address(getTokenRegistry(ethereum))
address(getTokenRegistry(localDomainName))
);
vm.label(address(tokenRegistry), "tokenRegistry");
bridgeRouter = IBridgeRouterHarness(address(getBridgeRouter(ethereum)));
bridgeRouter = IBridgeRouterHarness(
address(getBridgeRouter(localDomainName))
);
vm.label(address(bridgeRouter), "bridgeRouter");
// upgrade to harness
setUp_upgradeTokenRegistryHarness();
setUp_upgradeBridgeRouterHarness();
// load necessary contracts
xAppConnectionManager = getXAppConnectionManager(ethereum);
xAppConnectionManager = getXAppConnectionManager(localDomainName);
vm.label(address(xAppConnectionManager), "XAppConnectionManager");
upgradeBeaconController = getUpgradeBeaconController(ethereum);
upgradeBeaconController = getUpgradeBeaconController(localDomainName);
vm.label(address(upgradeBeaconController), "upgradeBeaconController");
tokenBeacon = UpgradeBeacon(payable(tokenRegistry.tokenBeacon()));
vm.label(address(tokenBeacon), "tokenBeacon");
bridgeToken = BridgeToken(beaconImplementation(tokenBeacon));
vm.label(address(bridgeToken), "bridgeToken");
// home needed for vm.expectCall
home = address(getHome("ethereum"));
home = address(getHome(localDomainName));
vm.label(home, "home");
BridgeRouterBaseTest.setUp_testFixtures();
}
Expand All @@ -54,13 +54,16 @@ contract BridgeRouterRebootTest is RebootTest, BridgeRouterTest {
vm.writeJson(
vm.toString(tokenRegistryHarnessImpl),
outputPath,
bridgeAttributePath(ethereum, "tokenRegistry.implementation")
bridgeAttributePath(localDomainName, "tokenRegistry.implementation")
);
reloadConfig();
pushSingleUpgrade(tokenRegistryUpgrade(ethereum), ethereum);
pushSingleUpgrade(
tokenRegistryUpgrade(localDomainName),
localDomainName
);
prankExecuteRecoveryManager(
address(getGovernanceRouter(ethereum)),
getDomainNumber(ethereum)
address(getGovernanceRouter(localDomainName)),
getDomainNumber(localDomainName)
);
}

Expand All @@ -70,25 +73,28 @@ contract BridgeRouterRebootTest is RebootTest, BridgeRouterTest {
vm.writeJson(
vm.toString(bridgeRouterHarnessImpl),
outputPath,
bridgeAttributePath(ethereum, "bridgeRouter.implementation")
bridgeAttributePath(localDomainName, "bridgeRouter.implementation")
);
reloadConfig();
pushSingleUpgrade(bridgeRouterUpgrade(ethereum), ethereum);
pushSingleUpgrade(
bridgeRouterUpgrade(localDomainName),
localDomainName
);
prankExecuteRecoveryManager(
address(getGovernanceRouter(ethereum)),
getDomainNumber(ethereum)
address(getGovernanceRouter(localDomainName)),
getDomainNumber(localDomainName)
);
}

function test_setUp_rebootBridgeRouter() public {
// check that the harnesses have harness methods available
assertEq(
bridgeRouterHarnessImpl,
bridgeRouterUpgrade(ethereum).implementation
bridgeRouterUpgrade(localDomainName).implementation
);
assertEq(
tokenRegistryHarnessImpl,
tokenRegistryUpgrade(ethereum).implementation
tokenRegistryUpgrade(localDomainName).implementation
);
bridgeRouter.exposed_dust(address(this));
tokenRegistry.exposed_localDomain();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,35 @@ contract EthereumBridgeRouterRebootTest is RebootTest, BridgeRouterTest {
address bridgeRouterHarnessImpl;
address tokenRegistryHarnessImpl;

string constant ethereum = "ethereum";

function setUp() public override(BridgeRouterBaseTest, NomadTest) {
setUpReboot("ethBridgeRouter");
require(
keccak256(bytes(localDomainName)) == keccak256(bytes("ethereum")),
"not ethereum bridge router"
);
// load proxies
tokenRegistry = TokenRegistryHarness(
address(getTokenRegistry(ethereum))
address(getTokenRegistry(localDomainName))
);
vm.label(address(tokenRegistry), "tokenRegistry");
bridgeRouter = IBridgeRouterHarness(address(getBridgeRouter(ethereum)));
bridgeRouter = IBridgeRouterHarness(
address(getBridgeRouter(localDomainName))
);
vm.label(address(bridgeRouter), "bridgeRouter");
// upgrade to harness
setUp_upgradeTokenRegistryHarness();
setUp_upgradeBridgeRouterHarness();
// load necessary contracts
xAppConnectionManager = getXAppConnectionManager(ethereum);
xAppConnectionManager = getXAppConnectionManager(localDomainName);
vm.label(address(xAppConnectionManager), "XAppConnectionManager");
upgradeBeaconController = getUpgradeBeaconController(ethereum);
upgradeBeaconController = getUpgradeBeaconController(localDomainName);
vm.label(address(upgradeBeaconController), "upgradeBeaconController");
tokenBeacon = UpgradeBeacon(payable(tokenRegistry.tokenBeacon()));
vm.label(address(tokenBeacon), "tokenBeacon");
bridgeToken = BridgeToken(beaconImplementation(tokenBeacon));
vm.label(address(bridgeToken), "bridgeToken");
// home needed for vm.expectCall
home = address(getHome("ethereum"));
home = address(getHome(localDomainName));
vm.label(home, "home");
BridgeRouterBaseTest.setUp_testFixtures();
}
Expand All @@ -54,43 +58,51 @@ contract EthereumBridgeRouterRebootTest is RebootTest, BridgeRouterTest {
vm.writeJson(
vm.toString(tokenRegistryHarnessImpl),
outputPath,
bridgeAttributePath(ethereum, "tokenRegistry.implementation")
bridgeAttributePath(localDomainName, "tokenRegistry.implementation")
);
reloadConfig();
pushSingleUpgrade(tokenRegistryUpgrade(ethereum), ethereum);
pushSingleUpgrade(
tokenRegistryUpgrade(localDomainName),
localDomainName
);
prankExecuteRecoveryManager(
address(getGovernanceRouter(ethereum)),
getDomainNumber(ethereum)
address(getGovernanceRouter(localDomainName)),
getDomainNumber(localDomainName)
);
}

function setUp_upgradeBridgeRouterHarness() public {
bridgeRouterHarnessImpl = address(
new EthereumBridgeRouterHarness(address(getAccountant(ethereum)))
new EthereumBridgeRouterHarness(
address(getAccountant(localDomainName))
)
);
vm.label(bridgeRouterHarnessImpl, "bridgeRouterHarnessImpl");
vm.writeJson(
vm.toString(bridgeRouterHarnessImpl),
outputPath,
bridgeAttributePath(ethereum, "bridgeRouter.implementation")
bridgeAttributePath(localDomainName, "bridgeRouter.implementation")
);
reloadConfig();
pushSingleUpgrade(bridgeRouterUpgrade(ethereum), ethereum);
pushSingleUpgrade(
bridgeRouterUpgrade(localDomainName),
localDomainName
);
prankExecuteRecoveryManager(
address(getGovernanceRouter(ethereum)),
getDomainNumber(ethereum)
address(getGovernanceRouter(localDomainName)),
getDomainNumber(localDomainName)
);
}

function test_setUp_rebootBridgeRouter() public {
// check that the harnesses have harness methods available
assertEq(
bridgeRouterHarnessImpl,
bridgeRouterUpgrade(ethereum).implementation
bridgeRouterUpgrade(localDomainName).implementation
);
assertEq(
tokenRegistryHarnessImpl,
tokenRegistryUpgrade(ethereum).implementation
tokenRegistryUpgrade(localDomainName).implementation
);
bridgeRouter.exposed_dust(address(this));
tokenRegistry.exposed_localDomain();
Expand Down
25 changes: 14 additions & 11 deletions packages/contracts-ops/contracts/test/RebootTokenRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ import {IBridgeRouterHarness} from "@nomad-xyz/contracts-bridge/contracts/test/h
contract TokenRegistryRebootTest is RebootTest, TokenRegistryTest {
address tokenRegistryHarnessImpl;

string constant ethereum = "ethereum";

function setUp() public override(NomadTest, BridgeTestFixture) {
setUpReboot("tokenRegistry");
tokenRegistry = TokenRegistryHarness(
address(getTokenRegistry(ethereum))
address(getTokenRegistry(localDomainName))
);
vm.label(address(tokenRegistry), "tokenRegistry");
bridgeRouter = IBridgeRouterHarness(address(getBridgeRouter(ethereum)));
bridgeRouter = IBridgeRouterHarness(
address(getBridgeRouter(localDomainName))
);
vm.label(address(bridgeRouter), "bridgeRouter");
// upgrade to harness
setUp_upgradeTokenRegistryHarness();
// load necessary contracts
xAppConnectionManager = getXAppConnectionManager(ethereum);
xAppConnectionManager = getXAppConnectionManager(localDomainName);
vm.label(address(xAppConnectionManager), "XAppConnectionManager");
upgradeBeaconController = getUpgradeBeaconController(ethereum);
upgradeBeaconController = getUpgradeBeaconController(localDomainName);
vm.label(address(upgradeBeaconController), "upgradeBeaconController");
tokenBeacon = UpgradeBeacon(payable(tokenRegistry.tokenBeacon()));
vm.label(address(tokenBeacon), "tokenBeacon");
bridgeToken = BridgeToken(beaconImplementation(tokenBeacon));
vm.label(address(bridgeToken), "bridgeToken");
// home needed for vm.expectCall
home = address(getHome(ethereum));
home = address(getHome(localDomainName));
vm.label(home, "home");
// BridgeTestFixture.setUp_testFixtures()
setUp_testFixtures();
Expand All @@ -50,13 +50,16 @@ contract TokenRegistryRebootTest is RebootTest, TokenRegistryTest {
vm.writeJson(
vm.toString(tokenRegistryHarnessImpl),
outputPath,
bridgeAttributePath(ethereum, "tokenRegistry.implementation")
bridgeAttributePath(localDomainName, "tokenRegistry.implementation")
);
reloadConfig();
pushSingleUpgrade(tokenRegistryUpgrade(ethereum), ethereum);
pushSingleUpgrade(
tokenRegistryUpgrade(localDomainName),
localDomainName
);
prankExecuteRecoveryManager(
address(getGovernanceRouter(ethereum)),
getDomainNumber(ethereum)
address(getGovernanceRouter(localDomainName)),
getDomainNumber(localDomainName)
);
}
}