From d731c783975bdbbf65a80922bfd60e8b5631dba1 Mon Sep 17 00:00:00 2001 From: wcgcyx Date: Wed, 6 Mar 2024 14:09:44 +1000 Subject: [PATCH] Cleanup --- .github/workflows/test.yml | 2 +- package.json | 2 +- scripts/localdev/chains.sh | 2 -- test/invariant/InvariantBridge.t.sol | 22 ++++++++++------------ 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dfefbb8f..c46f5c72 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -72,6 +72,6 @@ jobs: - name: Run Invariant Tests run: | - yarn local:threechains + yarn local:testchain forge test --match-path "test/invariant/**" -vvvvv id: invariant_test \ No newline at end of file diff --git a/package.json b/package.json index fb877879..10840708 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "local:ci": "cd scripts/localdev; rm -rf .child.bridge.contracts.json .root.bridge.contracts.json; ./ci.sh && ./deploy.sh && AXELAR_API_URL=skip npx mocha --require mocha-suppress-logs ../e2e/e2e.ts && ./stop.sh", "local:chainonly": "cd scripts/localdev; LOCAL_CHAIN_ONLY=true ./start.sh", "local:axelaronly": "cd scripts/localdev; npx ts-node axelar_setup.ts", - "local:threechains": "cd scripts/localdev; ./chains.sh", + "local:testchain": "cd scripts/localdev; ./chains.sh", "stop": "cd scripts/localdev; ./stop.sh" }, "author": "", diff --git a/scripts/localdev/chains.sh b/scripts/localdev/chains.sh index 31d3cb0b..d515fdd0 100755 --- a/scripts/localdev/chains.sh +++ b/scripts/localdev/chains.sh @@ -7,6 +7,4 @@ set -o pipefail # Start root & child chain. npx hardhat node --config ./rootchain.config.ts --port 8500 > /dev/null 2>&1 & -npx hardhat node --config ./childchain.config.ts --port 8501 > /dev/null 2>&1 & -npx hardhat node --config ./resetchain.config.ts --port 8502 > /dev/null 2>&1 & sleep 10 diff --git a/test/invariant/InvariantBridge.t.sol b/test/invariant/InvariantBridge.t.sol index dbcaa09a..12ec8695 100644 --- a/test/invariant/InvariantBridge.t.sol +++ b/test/invariant/InvariantBridge.t.sol @@ -16,15 +16,7 @@ import {RootERC20BridgeFlowRateHandler} from "./root/RootERC20BridgeFlowRateHand import "forge-std/console.sol"; contract InvariantBridge is Test { - string public constant CHILD_CHAIN_URL = "http://127.0.0.1:8500"; - string public constant ROOT_CHAIN_URL = "http://127.0.0.1:8501"; - // Forge has an issue that fails to reset state at the end of each run. - // For example, we found out that if the context stays at child chain at the end of setUp(), - // the state on child chain will not be reset or if the context stays at root chain, the state - // on the root chain will not be reset, which causes subsequent runs to fail. - // We introduced a third chain called reset chain and we make the context to stay on the reset chain - // in order to reset state on both child chain and root chain. - string public constant RESET_CHAIN_URL = "http://127.0.0.1:8502"; + string public constant CHAIN_URL = "http://127.0.0.1:8500"; uint256 public constant IMX_DEPOSIT_LIMIT = 10000 ether; uint256 public constant MAX_AMOUNT = 10000; address public constant ADMIN = address(0x111); @@ -49,9 +41,15 @@ contract InvariantBridge is Test { uint256 mappingGas; function setUp() public { - childId = vm.createFork(CHILD_CHAIN_URL); - rootId = vm.createFork(ROOT_CHAIN_URL); - resetId = vm.createFork(RESET_CHAIN_URL); + childId = vm.createFork(CHAIN_URL); + rootId = vm.createFork(CHAIN_URL); + // Forge has an issue that fails to reset state at the end of each run. + // For example, we found out that if the context stays at child chain at the end of setUp(), + // the state on child chain will not be reset or if the context stays at root chain, the state + // on the root chain will not be reset, which causes subsequent runs to fail. + // We introduced a third chain called reset chain and we make the context to stay on the reset chain + // in order to reset state on both child chain and root chain. + resetId = vm.createFork(CHAIN_URL); // Deploy contracts on child chain. vm.selectFork(childId);