Skip to content

Commit

Permalink
test(e2e): add amount args for ERC20 withdraw tests (#3113)
Browse files Browse the repository at this point in the history
* update test

* set args

* add missing test

* fix test
  • Loading branch information
lumtis authored Nov 8, 2024
1 parent b5985bc commit 6d7b91d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions cmd/zetae2e/local/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func startV2Tests(eg *errgroup.Group, conf config.Config, deployerRunner *runner
e2etests.TestV2ERC20WithdrawAndArbitraryCallName,
e2etests.TestV2ERC20WithdrawAndCallName,
e2etests.TestV2ERC20DepositAndCallNoMessageName,
e2etests.TestV2ERC20WithdrawAndCallNoMessageName,
))

// Test revert cases for gas token workflow
Expand Down
8 changes: 6 additions & 2 deletions e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,13 +964,17 @@ var AllE2ETests = []runner.E2ETest{
runner.NewE2ETest(
TestV2ERC20WithdrawAndCallName,
"withdraw ERC20 from ZEVM and authenticated call a contract using V2 contract",
[]runner.ArgDefinition{},
[]runner.ArgDefinition{
{Description: "amount", DefaultValue: "1000"},
},
TestV2ERC20WithdrawAndCall,
),
runner.NewE2ETest(
TestV2ERC20WithdrawAndCallNoMessageName,
"withdraw ERC20 from ZEVM and authenticated call a contract using V2 contract with no message",
[]runner.ArgDefinition{},
[]runner.ArgDefinition{
{Description: "amount", DefaultValue: "1000"},
},
TestV2ERC20WithdrawAndCallNoMessage,
),
runner.NewE2ETest(
Expand Down
9 changes: 5 additions & 4 deletions e2e/e2etests/test_v2_erc20_withdraw_and_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ import (
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types"
)

func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, _ []string) {
func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, args []string) {
require.Len(r, args, 1)

previousGasLimit := r.ZEVMAuth.GasLimit
r.ZEVMAuth.GasLimit = 10000000
defer func() {
r.ZEVMAuth.GasLimit = previousGasLimit
}()

// called with fixed amount without arg since onCall implementation is for TestDappV2 is simple and generic
// without decoding the payload and amount handling for erc20, purpose of test is to verify correct sender and payload are used
amount := big.NewInt(10000)
amount, ok := big.NewInt(0).SetString(args[0], 10)
require.True(r, ok, "Invalid amount specified for TestV2ERC20WithdrawAndCall")

payload := randomPayload(r)

Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_v2_erc20_withdraw_and_call_no_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestV2ERC20WithdrawAndCallNoMessage(r *runner.E2ERunner, args []string) {
// check called
messageIndex, err := r.TestDAppV2EVM.GetNoMessageIndex(&bind.CallOpts{}, r.EVMAddress())
require.NoError(r, err)
r.AssertTestDAppEVMCalled(true, messageIndex, amount)
r.AssertTestDAppEVMCalled(true, messageIndex, big.NewInt(0))

// check expected sender was used
senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage(
Expand Down

0 comments on commit 6d7b91d

Please sign in to comment.