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

test: fix upgrade tests #3196

Merged
merged 12 commits into from
Nov 22, 2024
6 changes: 5 additions & 1 deletion cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
logger := runner.NewLogger(verbose, color.FgWhite, "setup")

testStartTime := time.Now()

logger.Print("starting E2E tests")

if testAdmin {
Expand Down Expand Up @@ -323,14 +324,16 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestBitcoinDepositName,
e2etests.TestBitcoinDepositAndCallName,
e2etests.TestBitcoinDepositAndCallRevertName,
e2etests.TestBitcoinDepositAndCallRevertWithDustName,
e2etests.TestBitcoinStdMemoDepositName,
e2etests.TestBitcoinStdMemoDepositAndCallName,
e2etests.TestBitcoinStdMemoDepositAndCallRevertName,
e2etests.TestBitcoinStdMemoDepositAndCallRevertOtherAddressName,
e2etests.TestBitcoinStdMemoInscribedDepositAndCallName,
e2etests.TestCrosschainSwapName,
}
bitcoinDepositTestsAdvanced := []string{
e2etests.TestBitcoinDepositAndCallRevertWithDustName,
}
bitcoinWithdrawTests := []string{
e2etests.TestBitcoinWithdrawSegWitName,
e2etests.TestBitcoinWithdrawInvalidAddressName,
Expand Down Expand Up @@ -375,6 +378,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
erc20Tests = append(erc20Tests, erc20AdvancedTests...)
zetaTests = append(zetaTests, zetaAdvancedTests...)
zevmMPTests = append(zevmMPTests, zevmMPAdvancedTests...)
bitcoinDepositTests = append(bitcoinDepositTests, bitcoinDepositTestsAdvanced...)
bitcoinWithdrawTests = append(bitcoinWithdrawTests, bitcoinWithdrawTestsAdvanced...)
ethereumTests = append(ethereumTests, ethereumAdvancedTests...)
}
Expand Down
3 changes: 2 additions & 1 deletion contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; 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 local $E2E_ARGS --skip-setup --config "$deployed_config_path" --light --skip-precompiles ${COMMON_ARGS}
# skip-bitcoin-dust-withdraw flag can be removed after v23 is released
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --light --skip-precompiles ${COMMON_ARGS}
if [ $? -ne 0 ]; then
echo "first e2e failed"
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ func TestBitcoinDepositAndCallRevertWithDust(r *runner.E2ERunner, args []string)

// ASSERT
// Now we want to make sure the cctx is aborted with expected error message

// cctx status would be pending revert if using v21 or before
cctx := utils.WaitCctxAbortedByInboundHash(r.Ctx, r, txHash.String(), r.CctxClient)

require.True(r, cctx.GetCurrentOutboundParam().Amount.Uint64() < constant.BTCWithdrawalDustAmount)
require.True(r, strings.Contains(cctx.CctxStatus.ErrorMessage, crosschaintypes.ErrInvalidWithdrawalAmount.Error()))
}
2 changes: 1 addition & 1 deletion e2e/e2etests/test_crosschain_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
// if the tx fails due to already initialized, it will be ignored
_, err := r.UniswapV2Factory.CreatePair(r.ZEVMAuth, r.ERC20ZRC20Addr, r.BTCZRC20Addr)
if err != nil {
r.Logger.Print("ℹ️ create pair error")
r.Logger.Print("ℹ️ create pair error %s", err.Error())
lumtis marked this conversation as resolved.
Show resolved Hide resolved
}

txERC20ZRC20Approve, err := r.ERC20ZRC20.Approve(r.ZEVMAuth, r.UniswapV2RouterAddr, big.NewInt(1e18))
Expand Down
7 changes: 5 additions & 2 deletions e2e/e2etests/test_v2_deposit_and_call_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import (
func TestV2DepositAndCallSwap(r *runner.E2ERunner, _ []string) {
// create tokens pair (erc20 and eth)
tx, err := r.UniswapV2Factory.CreatePair(r.ZEVMAuth, r.ERC20ZRC20Addr, r.ETHZRC20Addr)
require.NoError(r, err)
utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
if err != nil {
r.Logger.Print("ℹ️ create pair error %s", err.Error())
} else {
utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
}
lumtis marked this conversation as resolved.
Show resolved Hide resolved

// approve router to spend tokens being swapped
tx, err = r.ERC20ZRC20.Approve(r.ZEVMAuth, r.UniswapV2RouterAddr, big.NewInt(1e18))
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_zrc20_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestZRC20Swap(r *runner.E2ERunner, _ []string) {
// if the tx fails due to already initialized, it will be ignored
tx, err := r.UniswapV2Factory.CreatePair(r.ZEVMAuth, r.ERC20ZRC20Addr, r.ETHZRC20Addr)
if err != nil {
r.Logger.Print("ℹ️ create pair error")
r.Logger.Print("ℹ️ create pair error %s", err.Error())
lumtis marked this conversation as resolved.
Show resolved Hide resolved
} else {
utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
}
Expand Down
Loading