diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index ffda89b919..c9c6eed25b 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -284,11 +284,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) { ethereumTests = append(ethereumTests, ethereumAdvancedTests...) } - //eg.Go(erc20TestRoutine(conf, deployerRunner, verbose, erc20Tests...)) + eg.Go(erc20TestRoutine(conf, deployerRunner, verbose, erc20Tests...)) eg.Go(zetaTestRoutine(conf, deployerRunner, verbose, zetaTests...)) - //eg.Go(zevmMPTestRoutine(conf, deployerRunner, verbose, zevmMPTests...)) + eg.Go(zevmMPTestRoutine(conf, deployerRunner, verbose, zevmMPTests...)) eg.Go(bitcoinTestRoutine(conf, deployerRunner, verbose, !skipBitcoinSetup, bitcoinTests...)) - //eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, ethereumTests...)) + eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, ethereumTests...)) } if testAdmin { diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index e91438cef2..55f0005185 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -136,7 +136,7 @@ var AllE2ETests = []runner.E2ETest{ TestZetaDepositInvalidAddressName, "deposit ZETA from Ethereum to ZEVM but use invalid address", []runner.ArgDefinition{ - {Description: "amount in azeta", DefaultValue: "1000000000000000000"}, + {Description: "amount in azeta", DefaultValue: "10000000000000000000"}, }, TestZetaDepositToInvalidAddress, ), diff --git a/e2e/e2etests/test_migrate_chain_support.go b/e2e/e2etests/test_migrate_chain_support.go index b8a92cd472..bee3fc7c9b 100644 --- a/e2e/e2etests/test_migrate_chain_support.go +++ b/e2e/e2etests/test_migrate_chain_support.go @@ -38,7 +38,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) { // deposit most of the ZETA supply on ZetaChain zetaAmount := big.NewInt(1e18) zetaAmount = zetaAmount.Mul(zetaAmount, big.NewInt(20_000_000_000)) // 20B Zeta - r.DepositZetaWithAmount(r.EVMAddress(), zetaAmount) + r.DepositZetaWithAmount(r.EVMAddress().Bytes(), zetaAmount) // do an ethers withdraw on the previous chain (0.01eth) for some interaction TestEtherWithdraw(r, []string{"10000000000000000"}) diff --git a/e2e/e2etests/test_zeta_deposit.go b/e2e/e2etests/test_zeta_deposit.go index c2f085a2f3..ea18f544c3 100644 --- a/e2e/e2etests/test_zeta_deposit.go +++ b/e2e/e2etests/test_zeta_deposit.go @@ -5,6 +5,7 @@ import ( "math/big" "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" @@ -16,7 +17,7 @@ func TestZetaDeposit(r *runner.E2ERunner, args []string) { amount, ok := big.NewInt(0).SetString(args[0], 10) require.True(r, ok, "Invalid amount specified for TestZetaDeposit.") - hash := r.DepositZetaWithAmount(r.EVMAddress(), amount) + hash := r.DepositZetaWithAmount(r.EVMAddress().Bytes(), amount) // wait for the cctx to be mined cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, hash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) @@ -29,11 +30,14 @@ func TestZetaDepositToInvalidAddress(r *runner.E2ERunner, args []string) { amount, ok := big.NewInt(0).SetString(args[0], 10) require.True(r, ok, "Invalid amount specified for TestZetaDeposit.") - hash := r.DepositZetaWithAmountToInvalidAddress(r.EVMAddress(), amount) + hash := r.DepositZetaWithAmount([]byte("invalid"), amount) - r.Logger.Print(fmt.Sprintf("Deposit to invalid address: %s", hash.Hex())) + r.Logger.Print(fmt.Sprintf("Deposit to invalid address tx hass: %s", hash.Hex())) // wait for the cctx to be mined cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, hash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) r.Logger.CCTX(*cctx, "deposit") + r.Logger.Print(fmt.Sprintf("CCTX: %v", cctx.Index)) + utils.RequireCCTXStatus(r, cctx, types.CctxStatus_Reverted, "deposit with invalid address") + utils.ContainsStringInCCTXStatusMessage(r, cctx, types.ErrInvalidReceiverAddress.Error(), "deposit with invalid address") } diff --git a/e2e/e2etests/test_zeta_deposit_new_address.go b/e2e/e2etests/test_zeta_deposit_new_address.go index 047fbd7042..62272224da 100644 --- a/e2e/e2etests/test_zeta_deposit_new_address.go +++ b/e2e/e2etests/test_zeta_deposit_new_address.go @@ -17,7 +17,7 @@ func TestZetaDepositNewAddress(r *runner.E2ERunner, args []string) { require.True(r, ok) newAddress := sample.EthAddress() - hash := r.DepositZetaWithAmount(newAddress, amount) + hash := r.DepositZetaWithAmount(newAddress.Bytes(), amount) // wait for the cctx to be mined cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, hash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) diff --git a/e2e/e2etests/test_zeta_deposit_restricted_address.go b/e2e/e2etests/test_zeta_deposit_restricted_address.go index d525a97d79..2d7da13e4a 100644 --- a/e2e/e2etests/test_zeta_deposit_restricted_address.go +++ b/e2e/e2etests/test_zeta_deposit_restricted_address.go @@ -17,5 +17,5 @@ func TestZetaDepositRestricted(r *runner.E2ERunner, args []string) { require.True(r, ok, "Invalid amount specified for TestZetaDepositRestricted.") // Deposit amount to restricted address - r.DepositZetaWithAmount(ethcommon.HexToAddress(testutils.RestrictedEVMAddressTest), amount) + r.DepositZetaWithAmount(ethcommon.HexToAddress(testutils.RestrictedEVMAddressTest).Bytes(), amount) } diff --git a/e2e/runner/zeta.go b/e2e/runner/zeta.go index dc35da6ed7..6c1efb74a8 100644 --- a/e2e/runner/zeta.go +++ b/e2e/runner/zeta.go @@ -95,11 +95,11 @@ func (r *E2ERunner) DepositZeta() ethcommon.Hash { amount := big.NewInt(1e18) amount = amount.Mul(amount, big.NewInt(100)) // 100 Zeta - return r.DepositZetaWithAmount(r.EVMAddress(), amount) + return r.DepositZetaWithAmount(r.EVMAddress().Bytes(), amount) } // DepositZetaWithAmount deposits ZETA on ZetaChain from the ZETA smart contract on EVM with the specified amount -func (r *E2ERunner) DepositZetaWithAmount(to ethcommon.Address, amount *big.Int) ethcommon.Hash { +func (r *E2ERunner) DepositZetaWithAmount(to []byte, amount *big.Int) ethcommon.Hash { tx, err := r.ZetaEth.Approve(r.EVMAuth, r.ConnectorEthAddr, amount) require.NoError(r, err) @@ -117,55 +117,7 @@ func (r *E2ERunner) DepositZetaWithAmount(to ethcommon.Address, amount *big.Int) // TODO: allow user to specify destination chain id // https://github.com/zeta-chain/node-private/issues/41 DestinationChainId: zetaChainID, - DestinationAddress: to.Bytes(), - DestinationGasLimit: big.NewInt(250_000), - Message: nil, - ZetaValueAndGas: amount, - ZetaParams: nil, - }) - require.NoError(r, err) - - r.Logger.Info("Send tx hash: %s", tx.Hash().Hex()) - - receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) - r.Logger.EVMReceipt(*receipt, "send") - r.requireTxSuccessful(receipt, "send tx failed") - - r.Logger.Info(" Logs:") - for _, log := range receipt.Logs { - sentLog, err := r.ConnectorEth.ParseZetaSent(*log) - if err == nil { - r.Logger.Info(" Connector: %s", r.ConnectorEthAddr.String()) - r.Logger.Info(" Dest Addr: %s", ethcommon.BytesToAddress(sentLog.DestinationAddress).Hex()) - r.Logger.Info(" Dest Chain: %d", sentLog.DestinationChainId) - r.Logger.Info(" Dest Gas: %d", sentLog.DestinationGasLimit) - r.Logger.Info(" Zeta Value: %d", sentLog.ZetaValueAndGas) - r.Logger.Info(" Block Num: %d", log.BlockNumber) - } - } - - return tx.Hash() -} - -func (r *E2ERunner) DepositZetaWithAmountToInvalidAddress(to ethcommon.Address, amount *big.Int) ethcommon.Hash { - tx, err := r.ZetaEth.Approve(r.EVMAuth, r.ConnectorEthAddr, amount) - require.NoError(r, err) - - r.Logger.Info("Approve tx hash: %s", tx.Hash().Hex()) - - receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) - r.Logger.EVMReceipt(*receipt, "approve") - r.requireTxSuccessful(receipt, "approve tx failed") - - // query the chain ID using zevm client - zetaChainID, err := r.ZEVMClient.ChainID(r.Ctx) - require.NoError(r, err) - - tx, err = r.ConnectorEth.Send(r.EVMAuth, zetaconnectoreth.ZetaInterfacesSendInput{ - // TODO: allow user to specify destination chain id - // https://github.com/zeta-chain/node-private/issues/41 - DestinationChainId: zetaChainID, - DestinationAddress: []byte("invalid"), + DestinationAddress: to, DestinationGasLimit: big.NewInt(250_000), Message: nil, ZetaValueAndGas: amount, diff --git a/e2e/utils/require.go b/e2e/utils/require.go index 7471bf9b4e..512b18028c 100644 --- a/e2e/utils/require.go +++ b/e2e/utils/require.go @@ -22,6 +22,17 @@ func RequireCCTXStatus( require.Equal(t, expected, cctx.CctxStatus.Status, msg+errSuffix(msgAndArgs...)) } +func ContainsStringInCCTXStatusMessage( + t require.TestingT, + cctx *crosschaintypes.CrossChainTx, + expected string, + msgAndArgs ...any) { + msg := fmt.Sprintf("cctx status message does not contain %s cctx index %s", expected, cctx.Index) + + require.NotNil(t, cctx.CctxStatus) + require.Contains(t, cctx.CctxStatus.StatusMessage, expected, msg+errSuffix(msgAndArgs...)) +} + // RequireTxSuccessful checks if the receipt status is successful. // Currently, it accepts eth receipt, but we can make this more generic by using type assertion. func RequireTxSuccessful(t require.TestingT, receipt *ethtypes.Receipt, msgAndArgs ...any) {