From e981a547774ec4e1f5fe7179e8cbbd3f4735b3d4 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 1 Jan 2024 19:43:39 +0100 Subject: [PATCH] add custom timeout for cctx and receipts --- cmd/zetae2e/root.go | 5 +++- .../orchestrator/smoketest/runner/evm.go | 10 ++++---- .../orchestrator/smoketest/runner/runner.go | 4 ++++ .../smoketest/runner/setup_evm.go | 16 ++++++------- .../smoketest/runner/setup_zeta.go | 4 ++-- .../orchestrator/smoketest/runner/zeta.go | 6 ++--- .../smoketest/smoketests/test_bitcoin.go | 6 ++--- .../smoketest/smoketests/test_context.go | 2 +- .../smoketests/test_crosschain_swap.go | 22 ++++++++--------- .../smoketest/smoketests/test_deposit_eth.go | 24 +++++++++---------- .../smoketests/test_erc20_deposit.go | 6 ++--- .../smoketest/smoketests/test_erc20_refund.go | 14 +++++------ .../smoketests/test_erc20_withdraw.go | 22 ++++++++++------- .../smoketests/test_message_passing.go | 18 +++++++------- .../smoketest/smoketests/test_pause_zrc20.go | 24 +++++++++---------- .../smoketests/test_update_bytecode.go | 10 ++++---- .../smoketests/test_zeta_in_and_out.go | 14 +++++------ .../smoketest/smoketests/test_zrc20_swap.go | 10 ++++---- .../orchestrator/smoketest/utils/evm.go | 12 +++++++++- .../orchestrator/smoketest/utils/zetacore.go | 13 +++++++--- 20 files changed, 136 insertions(+), 106 deletions(-) diff --git a/cmd/zetae2e/root.go b/cmd/zetae2e/root.go index e82756e213..8f514a6584 100644 --- a/cmd/zetae2e/root.go +++ b/cmd/zetae2e/root.go @@ -10,7 +10,10 @@ func NewRootCmd() *cobra.Command { Use: "zetae2e", Short: "E2E tests CLI", } - cmd.AddCommand(local.NewLocalCmd()) + cmd.AddCommand( + NewRunCmd(), + local.NewLocalCmd(), + ) return cmd } diff --git a/contrib/localnet/orchestrator/smoketest/runner/evm.go b/contrib/localnet/orchestrator/smoketest/runner/evm.go index 3a4236eb41..fc0734e895 100644 --- a/contrib/localnet/orchestrator/smoketest/runner/evm.go +++ b/contrib/localnet/orchestrator/smoketest/runner/evm.go @@ -22,7 +22,7 @@ func (sm *SmokeTestRunner) WaitForTxReceiptOnEvm(tx *ethtypes.Transaction) { }() sm.Lock() - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("tx failed") } @@ -42,7 +42,7 @@ func (sm *SmokeTestRunner) MintUSDTOnEvm(amountUSDT int64) { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("mint failed") } @@ -84,7 +84,7 @@ func (sm *SmokeTestRunner) DepositERC20WithAmountAndMessage(amount *big.Int, msg if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("approve failed") } @@ -94,7 +94,7 @@ func (sm *SmokeTestRunner) DepositERC20WithAmountAndMessage(amount *big.Int, msg if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("deposit failed") } @@ -129,7 +129,7 @@ func (sm *SmokeTestRunner) DepositEther(testHeader bool) ethcommon.Hash { } sm.Logger.Info("GOERLI tx sent: %s; to %s, nonce %d", signedTx.Hash().String(), signedTx.To().Hex(), signedTx.Nonce()) - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("deposit failed") } diff --git a/contrib/localnet/orchestrator/smoketest/runner/runner.go b/contrib/localnet/orchestrator/smoketest/runner/runner.go index 29cb9149d9..c78b99c029 100644 --- a/contrib/localnet/orchestrator/smoketest/runner/runner.go +++ b/contrib/localnet/orchestrator/smoketest/runner/runner.go @@ -88,6 +88,10 @@ type SmokeTestRunner struct { SystemContractAddr ethcommon.Address SystemContract *systemcontract.SystemContract + // config + CctxTimeout time.Duration + ReceiptTimeout time.Duration + // other Name string Ctx context.Context diff --git a/contrib/localnet/orchestrator/smoketest/runner/setup_evm.go b/contrib/localnet/orchestrator/smoketest/runner/setup_evm.go index 7902e25b06..5d89d9a3e4 100644 --- a/contrib/localnet/orchestrator/smoketest/runner/setup_evm.go +++ b/contrib/localnet/orchestrator/smoketest/runner/setup_evm.go @@ -136,22 +136,22 @@ func (sm *SmokeTestRunner) SetupEVM(contractsDeployed bool) { sm.Logger.Info("TestDApp contract address: %s, tx hash: %s", appAddr.Hex(), txApp.Hash().Hex()) // check contract deployment receipt - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txDonation, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txDonation, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("GOERLI donation tx failed") } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txZetaEth, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txZetaEth, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("ZetaEth deployment failed") } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txConnector, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txConnector, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("ZetaConnectorEth deployment failed") } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txCustody, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txCustody, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("ERC20Custody deployment failed") } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txUSDT, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txUSDT, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("USDT deployment failed") } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txApp, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txApp, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("TestDApp deployment failed") } @@ -162,7 +162,7 @@ func (sm *SmokeTestRunner) SetupEVM(contractsDeployed bool) { if err != nil { panic(err) } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txWhitelist, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txWhitelist, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("USDT whitelist failed") } @@ -171,7 +171,7 @@ func (sm *SmokeTestRunner) SetupEVM(contractsDeployed bool) { if err != nil { panic(err) } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txCustody, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, txCustody, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("USDT update TSS address failed") } sm.Logger.Info("TSS set receipt tx hash: %s", txCustody.Hash().Hex()) diff --git a/contrib/localnet/orchestrator/smoketest/runner/setup_zeta.go b/contrib/localnet/orchestrator/smoketest/runner/setup_zeta.go index 3da4079162..1a04830556 100644 --- a/contrib/localnet/orchestrator/smoketest/runner/setup_zeta.go +++ b/contrib/localnet/orchestrator/smoketest/runner/setup_zeta.go @@ -120,7 +120,7 @@ func (sm *SmokeTestRunner) SetupZEVMSwapApp() { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("ZEVMSwapApp deployment failed") } @@ -134,7 +134,7 @@ func (sm *SmokeTestRunner) SetupContextApp() { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("ContextApp deployment failed") } diff --git a/contrib/localnet/orchestrator/smoketest/runner/zeta.go b/contrib/localnet/orchestrator/smoketest/runner/zeta.go index f102840535..bac7f37431 100644 --- a/contrib/localnet/orchestrator/smoketest/runner/zeta.go +++ b/contrib/localnet/orchestrator/smoketest/runner/zeta.go @@ -20,7 +20,7 @@ func (sm *SmokeTestRunner) WaitForMinedCCTX(txHash ethcommon.Hash) { }() sm.Lock() - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, txHash.Hex(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, txHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) if cctx.CctxStatus.Status != types.CctxStatus_OutboundMined { panic(fmt.Sprintf("expected cctx status to be mined; got %s, message: %s", cctx.CctxStatus.Status.String(), @@ -62,7 +62,7 @@ func (sm *SmokeTestRunner) DepositZeta() ethcommon.Hash { panic(err) } sm.Logger.Info("Approve tx hash: %s", tx.Hash().Hex()) - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("approve tx failed") } @@ -83,7 +83,7 @@ func (sm *SmokeTestRunner) DepositZeta() ethcommon.Hash { } sm.Logger.Info("Send tx hash: %s", tx.Hash().Hex()) - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic(fmt.Sprintf("expected tx receipt status to be 1; got %d", receipt.Status)) } diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_bitcoin.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_bitcoin.go index d817edef1d..02a84e8403 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_bitcoin.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_bitcoin.go @@ -24,7 +24,7 @@ func WithdrawBitcoin(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic(fmt.Errorf("approve receipt status is not 1")) } @@ -37,7 +37,7 @@ func WithdrawBitcoin(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic(fmt.Errorf("withdraw receipt status is not 1")) } @@ -48,7 +48,7 @@ func WithdrawBitcoin(sm *runner.SmokeTestRunner) { panic(err) } - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.Hex(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) outTxHash := cctx.GetCurrentOutTxParam().OutboundTxHash hash, err := chainhash.NewHashFromStr(outTxHash) if err != nil { diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_context.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_context.go index 657c59e03e..63c266f311 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_context.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_context.go @@ -23,7 +23,7 @@ func TestContextUpgrade(sm *runner.SmokeTestRunner) { } sm.Logger.Info("GOERLI tx sent: %s; to %s, nonce %d", signedTx.Hash().String(), signedTx.To().Hex(), signedTx.Nonce()) - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("tx failed") } diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_crosschain_swap.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_crosschain_swap.go index 3398d77af7..166a6dfec2 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_crosschain_swap.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_crosschain_swap.go @@ -42,19 +42,19 @@ func TestCrosschainSwap(sm *runner.SmokeTestRunner) { panic(err) } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txCreatePair, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txCreatePair, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("create pair failed") } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txUSDTApprove, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txUSDTApprove, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("usdt approve failed") } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txBTCApprove, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txBTCApprove, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("btc approve failed") } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txTransferETH, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txTransferETH, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("ETH ZRC20 transfer failed") } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txTransferBTC, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txTransferBTC, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("BTC ZRC20 transfer failed") } @@ -74,7 +74,7 @@ func TestCrosschainSwap(sm *runner.SmokeTestRunner) { panic(fmt.Sprintf("Error liq %s", err.Error())) } - if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txAddLiquidity, sm.Logger); receipt.Status != 1 { + if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txAddLiquidity, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 { panic("add liq receipt status is not 1") } @@ -93,7 +93,7 @@ func TestCrosschainSwap(sm *runner.SmokeTestRunner) { sm.Logger.Info("***** First test: USDT -> BTC") // Should deposit USDT for swap, swap for BTC and withdraw BTC txHash := sm.DepositERC20WithAmountAndMessage(big.NewInt(8e7), msg) - cctx1 := utils.WaitCctxMinedByInTxHash(sm.Ctx, txHash.Hex(), sm.CctxClient, sm.Logger) + cctx1 := utils.WaitCctxMinedByInTxHash(sm.Ctx, txHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) // check the cctx status if cctx1.CctxStatus.Status != types.CctxStatus_OutboundMined { @@ -108,7 +108,7 @@ func TestCrosschainSwap(sm *runner.SmokeTestRunner) { stop := sm.MineBlocks() // cctx1 index acts like the inTxHash for the second cctx (the one that withdraws BTC) - cctx2 := utils.WaitCctxMinedByInTxHash(sm.Ctx, cctx1.Index, sm.CctxClient, sm.Logger) + cctx2 := utils.WaitCctxMinedByInTxHash(sm.Ctx, cctx1.Index, sm.CctxClient, sm.Logger, sm.CctxTimeout) // check the cctx status if cctx2.CctxStatus.Status != types.CctxStatus_OutboundMined { @@ -152,7 +152,7 @@ func TestCrosschainSwap(sm *runner.SmokeTestRunner) { panic(err) } - cctx3 := utils.WaitCctxMinedByInTxHash(sm.Ctx, txID.String(), sm.CctxClient, sm.Logger) + cctx3 := utils.WaitCctxMinedByInTxHash(sm.Ctx, txID.String(), sm.CctxClient, sm.Logger, sm.CctxTimeout) if cctx3.CctxStatus.Status != types.CctxStatus_OutboundMined { panic(fmt.Sprintf( "expected outbound mined status; got %s, message: %s", @@ -165,7 +165,7 @@ func TestCrosschainSwap(sm *runner.SmokeTestRunner) { sm.Logger.Info(" status %s", cctx3.CctxStatus.Status.String()) sm.Logger.Info(" status msg: %s", cctx3.CctxStatus.StatusMessage) - cctx4 := utils.WaitCctxMinedByInTxHash(sm.Ctx, cctx3.Index, sm.CctxClient, sm.Logger) + cctx4 := utils.WaitCctxMinedByInTxHash(sm.Ctx, cctx3.Index, sm.CctxClient, sm.Logger, sm.CctxTimeout) if cctx4.CctxStatus.Status != types.CctxStatus_OutboundMined { panic(fmt.Sprintf( "expected outbound mined status; got %s, message: %s", @@ -211,7 +211,7 @@ func TestCrosschainSwap(sm *runner.SmokeTestRunner) { panic(err) } - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, txid.String(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, txid.String(), sm.CctxClient, sm.Logger, sm.CctxTimeout) sm.Logger.Info("cctx3 index %s", cctx.Index) sm.Logger.Info(" inbound tx hash %s", cctx.InboundTxParams.InboundTxObservedHash) sm.Logger.Info(" status %s", cctx.CctxStatus.Status.String()) diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_deposit_eth.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_deposit_eth.go index 9b838a2e44..444009af35 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_deposit_eth.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_deposit_eth.go @@ -60,11 +60,11 @@ func TestEtherDepositAndCall(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("tx failed") } - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) if cctx.CctxStatus.Status != types.CctxStatus_OutboundMined { panic(fmt.Sprintf("expected cctx status to be mined; got %s", cctx.CctxStatus.Status)) } @@ -109,11 +109,11 @@ func TestEtherDepositAndCall(sm *runner.SmokeTestRunner) { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("tx failed") } - cctx = utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger) + cctx = utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) if cctx.CctxStatus.Status != types.CctxStatus_Reverted { panic(fmt.Sprintf("expected cctx status to be reverted; got %s", cctx.CctxStatus.Status)) } @@ -164,7 +164,7 @@ func TestDepositAndCallRefund(sm *runner.SmokeTestRunner) { panic(err) } sm.Logger.Info("GOERLI tx sent: %s; to %s, nonce %d", signedTx.Hash().String(), signedTx.To().Hex(), signedTx.Nonce()) - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("GOERLI tx receipt: %d", receipt.Status) sm.Logger.Info(" tx hash: %s", receipt.TxHash.String()) sm.Logger.Info(" to: %s", signedTx.To().String()) @@ -172,7 +172,7 @@ func TestDepositAndCallRefund(sm *runner.SmokeTestRunner) { sm.Logger.Info(" block num: %d", receipt.BlockNumber) func() { - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) sm.Logger.Info("cctx status message: %s", cctx.CctxStatus.StatusMessage) revertTxHash := cctx.GetCurrentOutTxParam().OutboundTxHash sm.Logger.Info("GOERLI revert tx receipt: status %d", receipt.Status) @@ -249,11 +249,11 @@ func TestDepositEtherLiquidityCap(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("deposit eth tx failed") } - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) if cctx.CctxStatus.Status != types.CctxStatus_Reverted { panic(fmt.Sprintf("expected cctx status to be Reverted; got %s", cctx.CctxStatus.Status)) } @@ -268,11 +268,11 @@ func TestDepositEtherLiquidityCap(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("deposit eth tx failed") } - utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger) + utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) expectedBalance := big.NewInt(0).Add(initialBal, big.NewInt(1e15)) bal, err := sm.ETHZRC20.BalanceOf(&bind.CallOpts{}, sm.DeployerAddress) @@ -303,11 +303,11 @@ func TestDepositEtherLiquidityCap(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("deposit eth tx failed") } - utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger) + utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) expectedBalance = big.NewInt(0).Add(initialBal, big.NewInt(1e17)) bal, err = sm.ETHZRC20.BalanceOf(&bind.CallOpts{}, sm.DeployerAddress) diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_deposit.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_deposit.go index 83a8a3e28e..d9439331e9 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_deposit.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_deposit.go @@ -21,7 +21,7 @@ func TestMultipleERC20Deposit(sm *runner.SmokeTestRunner) { panic(err) } txhash := MultipleDeposits(sm, big.NewInt(1e9), big.NewInt(3)) - cctxs := utils.WaitCctxsMinedByInTxHash(sm.Ctx, txhash.Hex(), sm.CctxClient, 3, sm.Logger) + cctxs := utils.WaitCctxsMinedByInTxHash(sm.Ctx, txhash.Hex(), sm.CctxClient, 3, sm.Logger, sm.CctxTimeout) if len(cctxs) != 3 { panic(fmt.Sprintf("cctxs length is not correct: %d", len(cctxs))) } @@ -51,7 +51,7 @@ func MultipleDeposits(sm *runner.SmokeTestRunner, amount, count *big.Int) ethcom if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("approve failed") } @@ -62,7 +62,7 @@ func MultipleDeposits(sm *runner.SmokeTestRunner, amount, count *big.Int) ethcom if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("deposits failed") } diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_refund.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_refund.go index 4d2341ce20..7834baacfa 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_refund.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_refund.go @@ -31,7 +31,7 @@ func TestERC20DepositAndCallRefund(sm *runner.SmokeTestRunner) { } // There is no liquidity pool, therefore the cctx should abort - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, inTxHash, sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, inTxHash, sm.CctxClient, sm.Logger, sm.CctxTimeout) if cctx.CctxStatus.Status != types.CctxStatus_Aborted { panic(fmt.Sprintf("expected cctx status to be Aborted; got %s", cctx.CctxStatus.Status)) } @@ -71,7 +71,7 @@ func TestERC20DepositAndCallRefund(sm *runner.SmokeTestRunner) { goerliBalanceAfterSend := big.NewInt(0).Sub(goerliBalance, amount) // there is a liquidity pool, therefore the cctx should revert - cctx = utils.WaitCctxMinedByInTxHash(sm.Ctx, inTxHash, sm.CctxClient, sm.Logger) + cctx = utils.WaitCctxMinedByInTxHash(sm.Ctx, inTxHash, sm.CctxClient, sm.Logger, sm.CctxTimeout) // the revert tx creation will fail because the sender, used as the recipient, is not defined in the cctx if cctx.CctxStatus.Status != types.CctxStatus_Reverted { @@ -123,13 +123,13 @@ func TestERC20DepositAndCallRefund(sm *runner.SmokeTestRunner) { func createZetaERC20LiquidityPool(sm *runner.SmokeTestRunner) error { amount := big.NewInt(1e10) txHash := sm.DepositERC20WithAmountAndMessage(amount, []byte{}) - utils.WaitCctxMinedByInTxHash(sm.Ctx, txHash.Hex(), sm.CctxClient, sm.Logger) + utils.WaitCctxMinedByInTxHash(sm.Ctx, txHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) tx, err := sm.USDTZRC20.Approve(sm.ZevmAuth, sm.UniswapV2RouterAddr, big.NewInt(1e10)) if err != nil { return err } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { return errors.New("approve failed") } @@ -149,7 +149,7 @@ func createZetaERC20LiquidityPool(sm *runner.SmokeTestRunner) error { if err != nil { return err } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { return fmt.Errorf("add liquidity failed") } @@ -163,7 +163,7 @@ func sendInvalidUSDTDeposit(sm *runner.SmokeTestRunner, amount *big.Int) (string if err != nil { return "", err } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("USDT Approve receipt tx hash: %s", tx.Hash().Hex()) tx, err = sm.ERC20Custody.Deposit( @@ -178,7 +178,7 @@ func sendInvalidUSDTDeposit(sm *runner.SmokeTestRunner, amount *big.Int) (string } sm.Logger.Info("GOERLI tx sent: %s; to %s, nonce %d", tx.Hash().String(), tx.To().Hex(), tx.Nonce()) - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { return "", errors.New("expected the tx receipt to have status 1; got 0") } diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_withdraw.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_withdraw.go index 758c2a2562..4dad98d96a 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_withdraw.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_withdraw.go @@ -18,7 +18,7 @@ func TestWithdrawERC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("approve failed") } @@ -29,18 +29,24 @@ func TestWithdrawERC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("Receipt txhash %s status %d", receipt.TxHash, receipt.Status) for _, log := range receipt.Logs { event, err := sm.USDTZRC20.ParseWithdrawal(*log) if err != nil { continue } - sm.Logger.Info(" logs: from %s, to %x, value %d, gasfee %d", event.From.Hex(), event.To, event.Value, event.Gasfee) + sm.Logger.Info( + " logs: from %s, to %x, value %d, gasfee %d", + event.From.Hex(), + event.To, + event.Value, + event.Gasfee, + ) } // verify the withdraw value - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.Hex(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) verifyTransferAmountFromCCTX(sm, cctx, 100) } @@ -56,7 +62,7 @@ func TestMultipleWithdraws(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("approve failed") } @@ -67,7 +73,7 @@ func TestMultipleWithdraws(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("approve gas token failed") } @@ -95,12 +101,12 @@ func TestMultipleWithdraws(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("withdraw failed") } - cctxs := utils.WaitCctxsMinedByInTxHash(sm.Ctx, tx.Hash().Hex(), sm.CctxClient, 3, sm.Logger) + cctxs := utils.WaitCctxsMinedByInTxHash(sm.Ctx, tx.Hash().Hex(), sm.CctxClient, 3, sm.Logger, sm.CctxTimeout) if len(cctxs) != 3 { panic(fmt.Sprintf("cctxs length is not correct: %d", len(cctxs))) } diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_message_passing.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_message_passing.go index 5dcac03d04..0ca5ae987b 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_message_passing.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_message_passing.go @@ -24,7 +24,7 @@ func TestMessagePassing(sm *runner.SmokeTestRunner) { } sm.Logger.Info("Approve tx hash: %s", tx.Hash().Hex()) - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("tx failed") } @@ -43,7 +43,7 @@ func TestMessagePassing(sm *runner.SmokeTestRunner) { } sm.Logger.Info("ConnectorEth.Send tx hash: %s", tx.Hash().Hex()) - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("tx failed") } @@ -61,7 +61,7 @@ func TestMessagePassing(sm *runner.SmokeTestRunner) { sm.Logger.Info("Waiting for ConnectorEth.Send CCTX to be mined...") sm.Logger.Info(" INTX hash: %s", receipt.TxHash.String()) - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.String(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.String(), sm.CctxClient, sm.Logger, sm.CctxTimeout) if cctx.CctxStatus.Status != cctxtypes.CctxStatus_OutboundMined { panic(fmt.Sprintf( "expected cctx status to be %s; got %s, message %s", @@ -102,7 +102,7 @@ func TestMessagePassingRevertFail(sm *runner.SmokeTestRunner) { panic(err) } sm.Logger.Info("Approve tx hash: %s", tx.Hash().Hex()) - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("tx failed") } @@ -120,7 +120,7 @@ func TestMessagePassingRevertFail(sm *runner.SmokeTestRunner) { panic(err) } sm.Logger.Info("ConnectorEth.Send tx hash: %s", tx.Hash().Hex()) - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("tx failed") } @@ -137,7 +137,7 @@ func TestMessagePassingRevertFail(sm *runner.SmokeTestRunner) { } // expect revert tx to fail - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.String(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.String(), sm.CctxClient, sm.Logger, sm.CctxTimeout) receipt, err = sm.GoerliClient.TransactionReceipt(sm.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) if err != nil { panic(err) @@ -164,7 +164,7 @@ func TestMessagePassingRevertSuccess(sm *runner.SmokeTestRunner) { } sm.Logger.Info("Approve tx hash: %s", tx.Hash().Hex()) - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("tx failed") } @@ -189,10 +189,10 @@ func TestMessagePassingRevertSuccess(sm *runner.SmokeTestRunner) { panic(err) } sm.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("TestDApp.SendHello tx receipt: status %d", receipt.Status) - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.String(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.String(), sm.CctxClient, sm.Logger, sm.CctxTimeout) if cctx.CctxStatus.Status != cctxtypes.CctxStatus_Reverted { panic("expected cctx to be reverted") } diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_pause_zrc20.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_pause_zrc20.go index b19cf307ec..5b6a9700b1 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_pause_zrc20.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_pause_zrc20.go @@ -24,7 +24,7 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("Vault approval should succeed") } @@ -32,7 +32,7 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("Vault approval should succeed") } @@ -68,7 +68,7 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 1 { panic("transfer should fail") } @@ -76,7 +76,7 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 1 { panic("burn should fail") } @@ -87,7 +87,7 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 1 { panic("deposit should fail") } @@ -99,7 +99,7 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("BTC transfer should succeed") } @@ -107,7 +107,7 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("BTC vault deposit should succeed") } @@ -117,11 +117,11 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, signedTx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("deposit eth tx failed") } - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, signedTx.Hash().Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout) if cctx.CctxStatus.Status != types.CctxStatus_Reverted { panic(fmt.Sprintf("expected cctx status to be Reverted; got %s", cctx.CctxStatus.Status)) } @@ -158,7 +158,7 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("transfer should succeed") } @@ -166,7 +166,7 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("burn should succeed") } @@ -176,7 +176,7 @@ func TestPauseZRC20(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status == 0 { panic("deposit should succeed") } diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_update_bytecode.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_update_bytecode.go index 8b6229b0b3..13377309ed 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_update_bytecode.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_update_bytecode.go @@ -20,7 +20,7 @@ func TestUpdateBytecode(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("approval failed") } @@ -39,7 +39,7 @@ func TestUpdateBytecode(sm *runner.SmokeTestRunner) { } // Wait for the contract to be deployed - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("contract deployment failed") } @@ -145,7 +145,7 @@ func TestUpdateBytecode(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("update new field failed") } @@ -162,7 +162,7 @@ func TestUpdateBytecode(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("update new field failed") } @@ -187,7 +187,7 @@ func TestUpdateBytecode(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) if receipt.Status != 1 { panic("transfer failed") } diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_zeta_in_and_out.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_zeta_in_and_out.go index 068cf1d21c..7db514951a 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_zeta_in_and_out.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_zeta_in_and_out.go @@ -48,7 +48,7 @@ func TestSendZetaOut(sm *runner.SmokeTestRunner) { zauth.Value = big.NewInt(0) sm.Logger.Info("Deposit tx hash: %s", tx.Hash().Hex()) - receipt := utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("Deposit tx receipt: status %d", receipt.Status) tx, err = wZeta.Approve(zauth, ConnectorZEVMAddr, amount) @@ -56,7 +56,7 @@ func TestSendZetaOut(sm *runner.SmokeTestRunner) { panic(err) } sm.Logger.Info("wzeta.approve tx hash: %s", tx.Hash().Hex()) - receipt = utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("approve tx receipt: status %d", receipt.Status) tx, err = ConnectorZEVM.Send(zauth, connectorzevm.ZetaInterfacesSendInput{ DestinationChainId: big.NewInt(1337), @@ -70,7 +70,7 @@ func TestSendZetaOut(sm *runner.SmokeTestRunner) { panic(err) } sm.Logger.Info("send tx hash: %s", tx.Hash().Hex()) - receipt = utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("send tx receipt: status %d", receipt.Status) sm.Logger.Info(" Logs:") for _, log := range receipt.Logs { @@ -84,7 +84,7 @@ func TestSendZetaOut(sm *runner.SmokeTestRunner) { } sm.Logger.Info("waiting for cctx status to change to final...") - cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, tx.Hash().Hex(), cctxClient, sm.Logger) + cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, tx.Hash().Hex(), cctxClient, sm.Logger, sm.CctxTimeout) if cctx.CctxStatus.Status != cctxtypes.CctxStatus_OutboundMined { panic(fmt.Errorf( "expected cctx status to be %s; got %s, message %s", @@ -142,7 +142,7 @@ func TestSendZetaOutBTCRevert(sm *runner.SmokeTestRunner) { zauth.Value = big.NewInt(0) sm.Logger.Info("Deposit tx hash: %s", tx.Hash().Hex()) - receipt := utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("Deposit tx receipt: status %d", receipt.Status) tx, err = wZeta.Approve(zauth, ConnectorZEVMAddr, big.NewInt(1e18)) @@ -150,7 +150,7 @@ func TestSendZetaOutBTCRevert(sm *runner.SmokeTestRunner) { panic(err) } sm.Logger.Info("wzeta.approve tx hash: %s", tx.Hash().Hex()) - receipt = utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("approve tx receipt: status %d", receipt.Status) tx, err = ConnectorZEVM.Send(zauth, connectorzevm.ZetaInterfacesSendInput{ DestinationChainId: big.NewInt(common.BtcRegtestChain().ChainId), @@ -164,7 +164,7 @@ func TestSendZetaOutBTCRevert(sm *runner.SmokeTestRunner) { panic(err) } sm.Logger.Info("send tx hash: %s", tx.Hash().Hex()) - receipt = utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, zevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("send tx receipt: status %d", receipt.Status) if receipt.Status != 0 { panic("Was able to send ZETA to BTC") diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_zrc20_swap.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_zrc20_swap.go index d7f1578812..1f96c46ff9 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_zrc20_swap.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_zrc20_swap.go @@ -19,7 +19,7 @@ func TestZRC20Swap(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) //sm.Logger.Info("USDT-ETH pair receipt txhash %s status %d", receipt.TxHash, receipt.Status) usdtEthPair, err := sm.UniswapV2Factory.GetPair(&bind.CallOpts{}, sm.USDTZRC20Addr, sm.ETHZRC20Addr) @@ -32,14 +32,14 @@ func TestZRC20Swap(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("USDT ZRC20 approval receipt txhash %s status %d", receipt.TxHash, receipt.Status) tx, err = sm.ETHZRC20.Approve(sm.ZevmAuth, sm.UniswapV2RouterAddr, big.NewInt(1e18)) if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("ETH ZRC20 approval receipt txhash %s status %d", receipt.TxHash, receipt.Status) // temporarily increase gas limit to 400000 @@ -63,7 +63,7 @@ func TestZRC20Swap(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("Add liquidity receipt txhash %s status %d", receipt.TxHash, receipt.Status) balETHBefore, err := sm.ETHZRC20.BalanceOf(&bind.CallOpts{}, sm.DeployerAddress) @@ -82,7 +82,7 @@ func TestZRC20Swap(sm *runner.SmokeTestRunner) { if err != nil { panic(err) } - receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger) + receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout) sm.Logger.Info("Swap USDT for ETH ZRC20 %s status %d", receipt.TxHash, receipt.Status) balETHAfter, err := sm.ETHZRC20.BalanceOf(&bind.CallOpts{}, sm.DeployerAddress) diff --git a/contrib/localnet/orchestrator/smoketest/utils/evm.go b/contrib/localnet/orchestrator/smoketest/utils/evm.go index dd8f2647c1..ec1273bcd4 100644 --- a/contrib/localnet/orchestrator/smoketest/utils/evm.go +++ b/contrib/localnet/orchestrator/smoketest/utils/evm.go @@ -13,6 +13,10 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) +const ( + DefaultReceiptTimeout = 30 * time.Second +) + func CheckNonce( ctx context.Context, client *ethclient.Client, @@ -36,10 +40,16 @@ func MustWaitForTxReceipt( client *ethclient.Client, tx *ethtypes.Transaction, logger infoLogger, + receiptTimeout time.Duration, ) *ethtypes.Receipt { + timeout := DefaultReceiptTimeout + if receiptTimeout != 0 { + timeout = receiptTimeout + } + start := time.Now() for { - if time.Since(start) > 30*time.Second { + if time.Since(start) > timeout { panic("waiting tx receipt timeout") } receipt, err := client.TransactionReceipt(ctx, tx.Hash()) diff --git a/contrib/localnet/orchestrator/smoketest/utils/zetacore.go b/contrib/localnet/orchestrator/smoketest/utils/zetacore.go index 8e485591c4..f1a18e4f71 100644 --- a/contrib/localnet/orchestrator/smoketest/utils/zetacore.go +++ b/contrib/localnet/orchestrator/smoketest/utils/zetacore.go @@ -13,7 +13,7 @@ import ( const ( FungibleAdminName = "fungibleadmin" - CctxTimeout = 3 * time.Minute + DefaultCctxTimeout = 3 * time.Minute ) // WaitCctxMinedByInTxHash waits until cctx is mined; returns the cctxIndex (the last one) @@ -22,8 +22,9 @@ func WaitCctxMinedByInTxHash( inTxHash string, cctxClient crosschaintypes.QueryClient, logger infoLogger, + cctxTimeout time.Duration, ) *crosschaintypes.CrossChainTx { - cctxs := WaitCctxsMinedByInTxHash(ctx, inTxHash, cctxClient, 1, logger) + cctxs := WaitCctxsMinedByInTxHash(ctx, inTxHash, cctxClient, 1, logger, cctxTimeout) if len(cctxs) == 0 { panic(fmt.Sprintf("cctx not found, inTxHash: %s", inTxHash)) } @@ -37,12 +38,18 @@ func WaitCctxsMinedByInTxHash( cctxClient crosschaintypes.QueryClient, cctxsCount int, logger infoLogger, + cctxTimeout time.Duration, ) []*crosschaintypes.CrossChainTx { startTime := time.Now() + timeout := DefaultCctxTimeout + if cctxTimeout != 0 { + timeout = cctxTimeout + } + // fetch cctxs by inTxHash for { - if time.Since(startTime) > CctxTimeout { + if time.Since(startTime) > timeout { panic(fmt.Sprintf("waiting cctx timeout, cctx not mined, inTxHash: %s", inTxHash)) }