Skip to content

Commit

Permalink
fix(e2e): remove hardcoded value for approval in withdrawal tests (#…
Browse files Browse the repository at this point in the history
…2527)

* erc

* ether

* tentative fix test

* fix 2

* set back 1 unit approval

* format
  • Loading branch information
lumtis authored Jul 24, 2024
1 parent e6ce681 commit 5c39726
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
7 changes: 2 additions & 5 deletions e2e/e2etests/test_erc20_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ import (
func TestERC20Withdraw(r *runner.E2ERunner, args []string) {
require.Len(r, args, 1)

approvedAmount := big.NewInt(1e18)

withdrawalAmount, ok := new(big.Int).SetString(args[0], 10)
require.True(r, ok, "Invalid withdrawal amount specified for TestERC20Withdraw.")
require.Equal(r, -1, withdrawalAmount.Cmp(approvedAmount))

// approve
tx, err := r.ETHZRC20.Approve(r.ZEVMAuth, r.ERC20ZRC20Addr, approvedAmount)
// approve 1 unit of the gas token to cover the gas fee
tx, err := r.ETHZRC20.Approve(r.ZEVMAuth, r.ERC20ZRC20Addr, big.NewInt(1e18))
require.NoError(r, err)

receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
Expand Down
13 changes: 3 additions & 10 deletions e2e/e2etests/test_eth_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,11 @@ import (
func TestEtherWithdraw(r *runner.E2ERunner, args []string) {
require.Len(r, args, 1)

approvedAmount := big.NewInt(1e18)
withdrawalAmount, ok := new(big.Int).SetString(args[0], 10)
require.True(r, ok, "Invalid withdrawal amount specified for TestEtherWithdraw.")
require.Equal(
r,
-1,
withdrawalAmount.Cmp(approvedAmount),
"Withdrawal amount must be less than the approved amount (1e18).",
)

// approve
tx, err := r.ETHZRC20.Approve(r.ZEVMAuth, r.ETHZRC20Addr, approvedAmount)

// approve 1 unit of the gas token to cover the gas fee transfer
tx, err := r.ETHZRC20.Approve(r.ZEVMAuth, r.ETHZRC20Addr, big.NewInt(1e18))
require.NoError(r, err)

r.Logger.EVMTransaction(*tx, "approve")
Expand Down
13 changes: 3 additions & 10 deletions e2e/e2etests/test_eth_withdraw_restricted_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@ import (
func TestEtherWithdrawRestricted(r *runner.E2ERunner, args []string) {
require.Len(r, args, 1)

approvedAmount := big.NewInt(1e18)

withdrawalAmount, ok := new(big.Int).SetString(args[0], 10)
require.True(r, ok)
require.True(
r,
withdrawalAmount.Cmp(approvedAmount) <= 0,
"Withdrawal amount must be less than the approved amount (1e18)",
)

// approve
tx, err := r.ETHZRC20.Approve(r.ZEVMAuth, r.ETHZRC20Addr, approvedAmount)

// approve 1 unit of the gas token to cover the gas fee transfer
tx, err := r.ETHZRC20.Approve(r.ZEVMAuth, r.ETHZRC20Addr, big.NewInt(1e18))
require.NoError(r, err)

r.Logger.EVMTransaction(*tx, "approve")
Expand Down

0 comments on commit 5c39726

Please sign in to comment.