diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 3d4f42e340..6bf686c638 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -242,6 +242,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { } zetaTests := []string{ e2etests.TestMessagePassingZEVMName, + e2etests.TestMessagePassingZEVMRevertName, e2etests.TestZetaWithdrawName, e2etests.TestMessagePassingName, e2etests.TestMessagePassingRevertFailName, diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 9fe3d5bdf4..ca2f60f2d6 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -26,6 +26,7 @@ const ( TestMessagePassingRevertFailName = "message_passing_revert_fail" TestMessagePassingRevertSuccessName = "message_passing_revert_success" TestMessagePassingZEVMName = "message_passing_zevm" + TestMessagePassingZEVMRevertName = "message_passing_revert_zevm" TestERC20DepositAndCallRefundName = "erc20_deposit_and_call_refund" TestEtherDepositAndCallName = "eth_deposit_and_call" TestDepositEtherLiquidityCapName = "deposit_eth_liquidity_cap" @@ -214,12 +215,20 @@ var AllE2ETests = []runner.E2ETest{ ), runner.NewE2ETest( TestMessagePassingZEVMName, - "evm->zevm message passing", + "evm -> zevm message passing contract call ", []runner.ArgDefinition{ runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000000"}, }, TestMessagePassingZEVM, ), + runner.NewE2ETest( + TestMessagePassingZEVMRevertName, + "evm -> zevm message passing and revert back to evm", + []runner.ArgDefinition{ + runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000000"}, + }, + TestMessagePassingZEVMRevert, + ), runner.NewE2ETest( TestMessagePassingName, "evm->evm message passing contract call", diff --git a/e2e/e2etests/test_message_passing_zevm.go b/e2e/e2etests/test_message_passing_zevm.go index 92ccb6dfdc..dda4c8f857 100644 --- a/e2e/e2etests/test_message_passing_zevm.go +++ b/e2e/e2etests/test_message_passing_zevm.go @@ -53,13 +53,64 @@ func TestMessagePassingZEVM(r *runner.E2ERunner, args []string) { r.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) - r.Logger.Print(fmt.Sprintf("Waiting for cctx , intx : %s", receipt.TxHash.String())) - // New inbound message picked up by zeta-clients and voted on by observers to initiate a contract call on zEVM cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) if cctx.CctxStatus.Status != cctxtypes.CctxStatus_OutboundMined { panic("expected cctx to be outbound_mined") } - r.Logger.Print("🔄 Cctx mined by outbound chain zevm", cctx.Index) + r.Logger.Print(fmt.Sprintf("🔄 Cctx mined for contract call chain zevm %s", cctx.Index)) +} + +func TestMessagePassingZEVMRevert(r *runner.E2ERunner, args []string) { + + if len(args) != 1 { + panic("TestMessagePassingRevert requires exactly one argument for the amount.") + } + + amount, ok := big.NewInt(0).SetString(args[0], 10) + if !ok { + panic("Invalid amount specified for TestMessagePassingRevert.") + } + + zEVMChainID, err := r.ZEVMClient.ChainID(r.Ctx) + if err != nil { + panic(err) + } + destinationAddress := r.ZevmTestDAppAddr + + //Use TestDapp to call the Send function on the EVM connector to create a message + auth := r.EVMAuth + tx, err := r.ZetaEth.Approve(auth, r.EvmTestDAppAddr, amount) + if err != nil { + panic(err) + } + r.Logger.Info("Approve tx hash: %s", tx.Hash().Hex()) + + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status != 1 { + panic("tx failed") + } + r.Logger.Info("Approve tx receipt: %d", receipt.Status) + + testDAppEVM, err := testdapp.NewTestDApp(r.EvmTestDAppAddr, r.EVMClient) + if err != nil { + panic(err) + } + + tx, err = testDAppEVM.SendHelloWorld(auth, destinationAddress, zEVMChainID, amount, true) + if err != nil { + panic(err) + } + r.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) + + r.Logger.Print(fmt.Sprintf("🔄 Revert tx intx : %d", receipt.TxHash.String())) + + // New inbound message picked up by zeta-clients and voted on by observers to initiate a contract call on zEVM + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != cctxtypes.CctxStatus_Reverted { + panic("expected cctx to be outbound_mined") + } + r.Logger.Print(fmt.Sprintf("🔄 Cctx mined for revert contract call chain zevm %s", cctx.Index)) }