Skip to content

Commit

Permalink
feat: enable e2e orchestrator restart (#2264)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Bertrand <[email protected]>
  • Loading branch information
gartnera and lumtis authored May 28, 2024
1 parent 4b3ca38 commit 8144a09
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
3 changes: 2 additions & 1 deletion cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C
conf.Contracts.EVM.ConnectorEthAddr = r.ConnectorEthAddr.Hex()
conf.Contracts.EVM.CustodyAddr = r.ERC20CustodyAddr.Hex()
conf.Contracts.EVM.ERC20 = r.ERC20Addr.Hex()
conf.Contracts.EVM.TestDappAddr = r.EvmTestDAppAddr.Hex()

conf.Contracts.ZEVM.SystemContractAddr = r.SystemContractAddr.Hex()
conf.Contracts.ZEVM.ETHZRC20Addr = r.ETHZRC20Addr.Hex()
Expand All @@ -107,7 +108,7 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C
conf.Contracts.ZEVM.WZetaAddr = r.WZetaAddr.Hex()
conf.Contracts.ZEVM.ZEVMSwapAppAddr = r.ZEVMSwapAppAddr.Hex()
conf.Contracts.ZEVM.ContextAppAddr = r.ContextAppAddr.Hex()
conf.Contracts.ZEVM.TestDappAddr = r.EvmTestDAppAddr.Hex()
conf.Contracts.ZEVM.TestDappAddr = r.ZevmTestDAppAddr.Hex()

return conf
}
8 changes: 7 additions & 1 deletion cmd/zetae2e/config/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,13 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
}
if c := conf.Contracts.ZEVM.TestDappAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid TestDappAddr: %s", c)
return fmt.Errorf("invalid ZevmTestDappAddr: %s", c)
}
r.ZevmTestDAppAddr = ethcommon.HexToAddress(c)
}
if c := conf.Contracts.EVM.TestDappAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid EvmTestDappAddr: %s", c)
}
r.EvmTestDAppAddr = ethcommon.HexToAddress(c)
}
Expand Down
40 changes: 28 additions & 12 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,29 @@ if [ "$OPTION" == "upgrade" ]; then
# Fetch the height of the upgrade, default is 225, if arg3 is passed, use that value
UPGRADE_HEIGHT=${3:-225}

# Run zetae2e, if the upgrade height is lower than 100, we use the setup-only flag
if [ "$UPGRADE_HEIGHT" -lt 100 ]; then
echo "running E2E command to setup the networks..."
if [[ ! -f deployed.yml ]]; then
zetae2e "$ZETAE2E_CMD" --setup-only --config-out deployed.yml --skip-header-proof
if [ $? -ne 0 ]; then
echo "e2e setup failed"
exit 1
fi
else
echo "skipping e2e setup because it has already been completed"
fi

# Run zetae2e, if the upgrade height is greater than 100 to populate the state
if [ "$UPGRADE_HEIGHT" -gt 100 ]; then
echo "running E2E command to setup the networks and populate the state..."

# Use light flag to ensure tests can complete before the upgrade height
zetae2e "$ZETAE2E_CMD" --config-out deployed.yml --light --skip-header-proof
fi
ZETAE2E_EXIT_CODE=$?

if [ $ZETAE2E_EXIT_CODE -ne 0 ]; then
echo "E2E setup failed"
exit 1
zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml --light --skip-header-proof
if [ $? -ne 0 ]; then
echo "first e2e failed"
exit 1
fi
fi

echo "E2E setup passed, waiting for upgrade height..."
echo "Waiting for upgrade height..."

OLD_VERSION=$(get_zetacored_version)

Expand Down Expand Up @@ -148,10 +153,21 @@ if [ "$OPTION" == "upgrade" ]; then
else

# Run the e2e tests normally
echo "running e2e setup..."

if [[ ! -f deployed.yml ]]; then
zetae2e "$ZETAE2E_CMD" --setup-only --config-out deployed.yml
if [ $? -ne 0 ]; then
echo "e2e setup failed"
exit 1
fi
else
echo "skipping e2e setup because it has already been completed"
fi

echo "running e2e tests..."

eval "zetae2e $ZETAE2E_CMD"
zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml
ZETAE2E_EXIT_CODE=$?

# if e2e passed, exit with 0, otherwise exit with 1
Expand Down
1 change: 1 addition & 0 deletions e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type EVM struct {
ConnectorEthAddr string `yaml:"connector_eth"`
CustodyAddr string `yaml:"custody"`
ERC20 string `yaml:"erc20"`
TestDappAddr string `yaml:"test_dapp"`
}

// ZEVM contains the addresses of predeployed contracts on the zEVM chain
Expand Down

0 comments on commit 8144a09

Please sign in to comment.