Skip to content

Commit

Permalink
test: fix upgrade tests (#3196)
Browse files Browse the repository at this point in the history
* stop e2e test from erroring out if uniswap pair already exists

* print error for pair exists revert

* match pending revert for v21 dtc dust amount withdraw

* remove dust withdraw from v21 previous version tests

* remove dust withdraw from v21 previous version tests

* add comment for v23

* adjust code format

* make generate

* revert skip btc dust

* remove flag name

* newline

* lint

---------

Co-authored-by: lumtis <[email protected]>
  • Loading branch information
kingpinXD and lumtis authored Nov 22, 2024
1 parent 495235e commit eaacc09
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
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())
}

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)
}

// 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())
} else {
utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
}
Expand Down

0 comments on commit eaacc09

Please sign in to comment.