Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Jan 14, 2025
1 parent 9410dc0 commit f4f689c
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 75 deletions.
108 changes: 54 additions & 54 deletions cmd/zetae2e/local/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,36 @@ import (

// startEVMTests starts EVM chains related tests in parallel
func startEVMTests(eg *errgroup.Group, conf config.Config, deployerRunner *runner.E2ERunner, verbose bool) {
// Test happy paths for gas token workflow
eg.Go(evmTestRoutine(conf, "eth", conf.AdditionalAccounts.UserEther, color.FgHiGreen, deployerRunner, verbose,
e2etests.TestETHDepositName,
e2etests.TestETHDepositAndCallName,
e2etests.TestETHWithdrawName,
e2etests.TestETHWithdrawAndArbitraryCallName,
e2etests.TestETHWithdrawAndCallName,
e2etests.TestETHWithdrawAndCallThroughContractName,
e2etests.TestZEVMToEVMArbitraryCallName,
e2etests.TestZEVMToEVMCallName,
e2etests.TestZEVMToEVMCallThroughContractName,
e2etests.TestEVMToZEVMCallName,
e2etests.TestETHDepositAndCallNoMessageName,
e2etests.TestETHWithdrawAndCallNoMessageName,
e2etests.TestEtherWithdrawRestrictedName,
))

// Test happy paths for erc20 token workflow
eg.Go(evmTestRoutine(conf, "erc20", conf.AdditionalAccounts.UserERC20, color.FgHiBlue, deployerRunner, verbose,
e2etests.TestETHDepositName, // necessary to pay fees on ZEVM
e2etests.TestERC20DepositName,
e2etests.TestERC20DepositAndCallName,
e2etests.TestERC20WithdrawName,
e2etests.TestERC20WithdrawAndArbitraryCallName,
e2etests.TestERC20WithdrawAndCallName,
e2etests.TestERC20DepositAndCallNoMessageName,
e2etests.TestERC20WithdrawAndCallNoMessageName,
e2etests.TestDepositAndCallSwapName,
e2etests.TestERC20DepositRestrictedName,
))
//// Test happy paths for gas token workflow
//eg.Go(evmTestRoutine(conf, "eth", conf.AdditionalAccounts.UserEther, color.FgHiGreen, deployerRunner, verbose,
// e2etests.TestETHDepositName,
// e2etests.TestETHDepositAndCallName,
// e2etests.TestETHWithdrawName,
// e2etests.TestETHWithdrawAndArbitraryCallName,
// e2etests.TestETHWithdrawAndCallName,
// e2etests.TestETHWithdrawAndCallThroughContractName,
// e2etests.TestZEVMToEVMArbitraryCallName,
// e2etests.TestZEVMToEVMCallName,
// e2etests.TestZEVMToEVMCallThroughContractName,
// e2etests.TestEVMToZEVMCallName,
// e2etests.TestETHDepositAndCallNoMessageName,
// e2etests.TestETHWithdrawAndCallNoMessageName,
// e2etests.TestEtherWithdrawRestrictedName,
//))
//
//// Test happy paths for erc20 token workflow
//eg.Go(evmTestRoutine(conf, "erc20", conf.AdditionalAccounts.UserERC20, color.FgHiBlue, deployerRunner, verbose,
// e2etests.TestETHDepositName, // necessary to pay fees on ZEVM
// e2etests.TestERC20DepositName,
// e2etests.TestERC20DepositAndCallName,
// e2etests.TestERC20WithdrawName,
// e2etests.TestERC20WithdrawAndArbitraryCallName,
// e2etests.TestERC20WithdrawAndCallName,
// e2etests.TestERC20DepositAndCallNoMessageName,
// e2etests.TestERC20WithdrawAndCallNoMessageName,
// e2etests.TestDepositAndCallSwapName,
// e2etests.TestERC20DepositRestrictedName,
//))

// Test revert cases for gas token workflow
eg.Go(
Expand All @@ -55,34 +55,34 @@ func startEVMTests(eg *errgroup.Group, conf config.Config, deployerRunner *runne
deployerRunner,
verbose,
e2etests.TestETHDepositName, // necessary to pay fees on ZEVM and withdraw
e2etests.TestETHDepositAndCallRevertName,
e2etests.TestETHDepositAndCallRevertWithCallName,
e2etests.TestETHWithdrawAndCallRevertName,
e2etests.TestETHWithdrawAndCallRevertWithCallName,
//e2etests.TestETHDepositAndCallRevertName,
//e2etests.TestETHDepositAndCallRevertWithCallName,
//e2etests.TestETHWithdrawAndCallRevertName,
//e2etests.TestETHWithdrawAndCallRevertWithCallName,
e2etests.TestETHWithdrawAndCallRevertWithWithdrawName,
e2etests.TestDepositAndCallOutOfGasName,
//e2etests.TestDepositAndCallOutOfGasName,
),
)

// Test revert cases for erc20 token workflow
eg.Go(
evmTestRoutine(
conf,
"erc20-revert",
conf.AdditionalAccounts.UserERC20Revert,
color.FgHiRed,
deployerRunner,
verbose,
e2etests.TestETHDepositName, // necessary to pay fees on ZEVM
e2etests.TestERC20DepositName, // necessary to have assets to withdraw
e2etests.TestOperationAddLiquidityETHName, // liquidity with gas and ERC20 are necessary for reverts
e2etests.TestOperationAddLiquidityERC20Name,
e2etests.TestERC20DepositAndCallRevertName,
e2etests.TestERC20DepositAndCallRevertWithCallName,
e2etests.TestERC20WithdrawAndCallRevertName,
e2etests.TestERC20WithdrawAndCallRevertWithCallName,
),
)
//// Test revert cases for erc20 token workflow
//eg.Go(
// evmTestRoutine(
// conf,
// "erc20-revert",
// conf.AdditionalAccounts.UserERC20Revert,
// color.FgHiRed,
// deployerRunner,
// verbose,
// e2etests.TestETHDepositName, // necessary to pay fees on ZEVM
// e2etests.TestERC20DepositName, // necessary to have assets to withdraw
// e2etests.TestOperationAddLiquidityETHName, // liquidity with gas and ERC20 are necessary for reverts
// e2etests.TestOperationAddLiquidityERC20Name,
// e2etests.TestERC20DepositAndCallRevertName,
// e2etests.TestERC20DepositAndCallRevertWithCallName,
// e2etests.TestERC20WithdrawAndCallRevertName,
// e2etests.TestERC20WithdrawAndCallRevertWithCallName,
// ),
//)
}

// evmTestRoutine runs EVM chain related e2e tests
Expand Down
24 changes: 8 additions & 16 deletions e2e/e2etests/test_eth_withdraw_and_call_revert_with_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package e2etests
import (
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/stretchr/testify/require"
"github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayzevm.sol"

Expand All @@ -17,10 +16,6 @@ func TestETHWithdrawAndCallRevertWithWithdraw(r *runner.E2ERunner, args []string

amount := utils.ParseBigInt(r, args[0])

payload := randomPayload(r)

r.AssertTestDAppZEVMCalled(false, payload, amount)

r.ApproveETHZRC20(r.GatewayZEVMAddr)

// perform the withdraw
Expand All @@ -37,17 +32,14 @@ func TestETHWithdrawAndCallRevertWithWithdraw(r *runner.E2ERunner, args []string
)

// wait for the cctx to be mined
cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
r.Logger.CCTX(*cctx, "withdraw")
require.Equal(r, crosschaintypes.CctxStatus_Reverted, cctx.CctxStatus.Status)
cctxRevert := utils.WaitCctxMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
r.Logger.CCTX(*cctxRevert, "withdraw")
require.Equal(r, crosschaintypes.CctxStatus_Reverted, cctxRevert.CctxStatus.Status)

r.AssertTestDAppZEVMCalled(true, payload, big.NewInt(0))
r.Logger.Print("cctxRevert")
r.Logger.Print(cctxRevert.String())

Check failure on line 40 in e2e/e2etests/test_eth_withdraw_and_call_revert_with_withdraw.go

View workflow job for this annotation

GitHub Actions / lint

printf: non-constant format string in call to (*github.com/zeta-chain/node/e2e/runner.Logger).Print (govet)
//cctxWithdrawFromRevert := utils.WaitCctxMinedByInboundHash(r.Ctx, cctxRevert, r.CctxClient, r.Logger, r.CctxTimeout)

// check expected sender was used
senderForMsg, err := r.TestDAppV2ZEVM.SenderWithMessage(
&bind.CallOpts{},
[]byte(payload),
)
require.NoError(r, err)
require.Equal(r, r.ZEVMAuth.From, senderForMsg)
// check the cctx status
//utils.RequireCCTXStatus(r, cctxWithdrawFromRevert, crosschaintypes.CctxStatus_OutboundMined)
}
22 changes: 17 additions & 5 deletions testutil/keeper/mocks/crosschain/fungible.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f4f689c

Please sign in to comment.