Skip to content

Commit

Permalink
fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Feb 9, 2024
1 parent 1c0663f commit 678594f
Show file tree
Hide file tree
Showing 26 changed files with 150 additions and 141 deletions.
5 changes: 3 additions & 2 deletions cmd/zetae2e/local/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package local
import (
"fmt"

"runtime"
"time"

"github.com/fatih/color"
"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/e2etests"
"github.com/zeta-chain/zetacore/e2e/runner"
"runtime"
"time"
)

// adminTestRoutine runs admin functions tests
Expand Down
1 change: 1 addition & 0 deletions cmd/zetae2e/show_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"errors"

"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
Expand Down
4 changes: 2 additions & 2 deletions e2e/e2etests/test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package e2etests

import (
"bytes"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
"math/big"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
)

// TestContextUpgrade tests sending ETH on ZetaChain and check context data
Expand Down
26 changes: 13 additions & 13 deletions e2e/e2etests/test_crosschain_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package e2etests

import (
"fmt"
"github.com/zeta-chain/zetacore/e2e/runner"
utils2 "github.com/zeta-chain/zetacore/e2e/utils"
"math/big"
"time"

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
"github.com/zeta-chain/zetacore/x/crosschain/types"
)

Expand Down Expand Up @@ -42,16 +42,16 @@ func TestCrosschainSwap(sm *runner.E2ERunner) {
panic(err)
}

if receipt := utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txUSDTApprove, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 {
if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txUSDTApprove, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 {
panic("usdt approve failed")
}
if receipt := utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txBTCApprove, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 {
if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txBTCApprove, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 {
panic("btc approve failed")
}
if receipt := utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txTransferETH, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 {
if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txTransferETH, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 {
panic("ETH ZRC20 transfer failed")
}
if receipt := utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txTransferBTC, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 {
if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txTransferBTC, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 {
panic("BTC ZRC20 transfer failed")
}

Expand All @@ -71,7 +71,7 @@ func TestCrosschainSwap(sm *runner.E2ERunner) {
panic(fmt.Sprintf("Error liq %s", err.Error()))
}

if receipt := utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txAddLiquidity, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 {
if receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, txAddLiquidity, sm.Logger, sm.ReceiptTimeout); receipt.Status != 1 {
panic("add liq receipt status is not 1")
}

Expand All @@ -90,7 +90,7 @@ func TestCrosschainSwap(sm *runner.E2ERunner) {
sm.Logger.Info("***** First test: USDT -> BTC")
// Should deposit USDT for swap, swap for BTC and withdraw BTC
txHash := sm.DepositERC20WithAmountAndMessage(big.NewInt(8e7), msg)
cctx1 := utils2.WaitCctxMinedByInTxHash(sm.Ctx, txHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout)
cctx1 := utils.WaitCctxMinedByInTxHash(sm.Ctx, txHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout)

// check the cctx status
if cctx1.CctxStatus.Status != types.CctxStatus_OutboundMined {
Expand All @@ -105,7 +105,7 @@ func TestCrosschainSwap(sm *runner.E2ERunner) {
stop := sm.MineBlocks()

// cctx1 index acts like the inTxHash for the second cctx (the one that withdraws BTC)
cctx2 := utils2.WaitCctxMinedByInTxHash(sm.Ctx, cctx1.Index, sm.CctxClient, sm.Logger, sm.CctxTimeout)
cctx2 := utils.WaitCctxMinedByInTxHash(sm.Ctx, cctx1.Index, sm.CctxClient, sm.Logger, sm.CctxTimeout)

// check the cctx status
if cctx2.CctxStatus.Status != types.CctxStatus_OutboundMined {
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestCrosschainSwap(sm *runner.E2ERunner) {
panic(err)
}

cctx3 := utils2.WaitCctxMinedByInTxHash(sm.Ctx, txID.String(), sm.CctxClient, sm.Logger, sm.CctxTimeout)
cctx3 := utils.WaitCctxMinedByInTxHash(sm.Ctx, txID.String(), sm.CctxClient, sm.Logger, sm.CctxTimeout)
if cctx3.CctxStatus.Status != types.CctxStatus_OutboundMined {
panic(fmt.Sprintf(
"expected outbound mined status; got %s, message: %s",
Expand All @@ -162,7 +162,7 @@ func TestCrosschainSwap(sm *runner.E2ERunner) {
sm.Logger.Info(" status %s", cctx3.CctxStatus.Status.String())
sm.Logger.Info(" status msg: %s", cctx3.CctxStatus.StatusMessage)

cctx4 := utils2.WaitCctxMinedByInTxHash(sm.Ctx, cctx3.Index, sm.CctxClient, sm.Logger, sm.CctxTimeout)
cctx4 := utils.WaitCctxMinedByInTxHash(sm.Ctx, cctx3.Index, sm.CctxClient, sm.Logger, sm.CctxTimeout)
if cctx4.CctxStatus.Status != types.CctxStatus_OutboundMined {
panic(fmt.Sprintf(
"expected outbound mined status; got %s, message: %s",
Expand Down Expand Up @@ -208,7 +208,7 @@ func TestCrosschainSwap(sm *runner.E2ERunner) {
panic(err)
}

cctx := utils2.WaitCctxMinedByInTxHash(sm.Ctx, txid.String(), sm.CctxClient, sm.Logger, sm.CctxTimeout)
cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, txid.String(), sm.CctxClient, sm.Logger, sm.CctxTimeout)
sm.Logger.Info("cctx3 index %s", cctx.Index)
sm.Logger.Info(" inbound tx hash %s", cctx.InboundTxParams.InboundTxObservedHash)
sm.Logger.Info(" status %s", cctx.CctxStatus.Status.String())
Expand All @@ -230,7 +230,7 @@ func TestCrosschainSwap(sm *runner.E2ERunner) {
sm.Logger.Info(" vout %d", vout.N)
sm.Logger.Info(" value %f", vout.Value)
sm.Logger.Info(" scriptPubKey %s", vout.ScriptPubKey.Hex)
sm.Logger.Info(" p2wpkh address: %s", utils2.ScriptPKToAddress(vout.ScriptPubKey.Hex, sm.BitcoinParams))
sm.Logger.Info(" p2wpkh address: %s", utils.ScriptPKToAddress(vout.ScriptPubKey.Hex, sm.BitcoinParams))
}
}

Expand Down
4 changes: 2 additions & 2 deletions e2e/e2etests/test_donation.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package e2etests

import (
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
"math/big"

"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
"github.com/zeta-chain/zetacore/zetaclient"
)

Expand Down
3 changes: 2 additions & 1 deletion e2e/e2etests/test_erc20_deposit.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package e2etests

import (
"math/big"

"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
"math/big"
)

func TestERC20Deposit(sm *runner.E2ERunner) {
Expand Down
10 changes: 5 additions & 5 deletions e2e/e2etests/test_erc20_multiple_deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package e2etests

import (
"fmt"
"github.com/zeta-chain/zetacore/e2e/runner"
utils2 "github.com/zeta-chain/zetacore/e2e/utils"
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
testcontract "github.com/zeta-chain/zetacore/testutil/contracts"
)

Expand All @@ -17,7 +17,7 @@ func TestMultipleERC20Deposit(sm *runner.E2ERunner) {
panic(err)
}
txhash := MultipleDeposits(sm, big.NewInt(1e9), big.NewInt(3))
cctxs := utils2.WaitCctxsMinedByInTxHash(sm.Ctx, txhash.Hex(), sm.CctxClient, 3, sm.Logger, sm.CctxTimeout)
cctxs := utils.WaitCctxsMinedByInTxHash(sm.Ctx, txhash.Hex(), sm.CctxClient, 3, sm.Logger, sm.CctxTimeout)
if len(cctxs) != 3 {
panic(fmt.Sprintf("cctxs length is not correct: %d", len(cctxs)))
}
Expand Down Expand Up @@ -47,7 +47,7 @@ func MultipleDeposits(sm *runner.E2ERunner, amount, count *big.Int) ethcommon.Ha
if err != nil {
panic(err)
}
receipt := utils2.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout)
if receipt.Status == 0 {
panic("approve failed")
}
Expand All @@ -58,7 +58,7 @@ func MultipleDeposits(sm *runner.E2ERunner, amount, count *big.Int) ethcommon.Ha
if err != nil {
panic(err)
}
receipt = utils2.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout)
if receipt.Status == 0 {
panic("deposits failed")
}
Expand Down
12 changes: 6 additions & 6 deletions e2e/e2etests/test_erc20_multiple_withdraws.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package e2etests

import (
"fmt"
"github.com/zeta-chain/zetacore/e2e/runner"
utils2 "github.com/zeta-chain/zetacore/e2e/utils"
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
testcontract "github.com/zeta-chain/zetacore/testutil/contracts"
)

Expand All @@ -22,7 +22,7 @@ func TestMultipleWithdraws(sm *runner.E2ERunner) {
if err != nil {
panic(err)
}
receipt := utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
if receipt.Status == 0 {
panic("approve failed")
}
Expand All @@ -33,7 +33,7 @@ func TestMultipleWithdraws(sm *runner.E2ERunner) {
if err != nil {
panic(err)
}
receipt = utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
if receipt.Status == 0 {
panic("approve gas token failed")
}
Expand Down Expand Up @@ -61,12 +61,12 @@ func TestMultipleWithdraws(sm *runner.E2ERunner) {
if err != nil {
panic(err)
}
receipt = utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
if receipt.Status == 0 {
panic("withdraw failed")
}

cctxs := utils2.WaitCctxsMinedByInTxHash(sm.Ctx, tx.Hash().Hex(), sm.CctxClient, 3, sm.Logger, sm.CctxTimeout)
cctxs := utils.WaitCctxsMinedByInTxHash(sm.Ctx, tx.Hash().Hex(), sm.CctxClient, 3, sm.Logger, sm.CctxTimeout)
if len(cctxs) != 3 {
panic(fmt.Sprintf("cctxs length is not correct: %d", len(cctxs)))
}
Expand Down
18 changes: 9 additions & 9 deletions e2e/e2etests/test_erc20_refund.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package e2etests
import (
"errors"
"fmt"
"github.com/zeta-chain/zetacore/e2e/runner"
utils2 "github.com/zeta-chain/zetacore/e2e/utils"
"math/big"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
"github.com/zeta-chain/zetacore/x/crosschain/types"
)

Expand All @@ -31,7 +31,7 @@ func TestERC20DepositAndCallRefund(sm *runner.E2ERunner) {
}

// There is no liquidity pool, therefore the cctx should abort
cctx := utils2.WaitCctxMinedByInTxHash(sm.Ctx, inTxHash, sm.CctxClient, sm.Logger, sm.CctxTimeout)
cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, inTxHash, sm.CctxClient, sm.Logger, sm.CctxTimeout)
sm.Logger.CCTX(*cctx, "deposit")
if cctx.CctxStatus.Status != types.CctxStatus_Aborted {
panic(fmt.Sprintf("expected cctx status to be Aborted; got %s", cctx.CctxStatus.Status))
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestERC20DepositAndCallRefund(sm *runner.E2ERunner) {
goerliBalanceAfterSend := big.NewInt(0).Sub(goerliBalance, amount)

// there is a liquidity pool, therefore the cctx should revert
cctx = utils2.WaitCctxMinedByInTxHash(sm.Ctx, inTxHash, sm.CctxClient, sm.Logger, sm.CctxTimeout)
cctx = utils.WaitCctxMinedByInTxHash(sm.Ctx, inTxHash, sm.CctxClient, sm.Logger, sm.CctxTimeout)

// the revert tx creation will fail because the sender, used as the recipient, is not defined in the cctx
if cctx.CctxStatus.Status != types.CctxStatus_Reverted {
Expand Down Expand Up @@ -124,13 +124,13 @@ func TestERC20DepositAndCallRefund(sm *runner.E2ERunner) {
func createZetaERC20LiquidityPool(sm *runner.E2ERunner) error {
amount := big.NewInt(1e10)
txHash := sm.DepositERC20WithAmountAndMessage(amount, []byte{})
utils2.WaitCctxMinedByInTxHash(sm.Ctx, txHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout)
utils.WaitCctxMinedByInTxHash(sm.Ctx, txHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout)

tx, err := sm.USDTZRC20.Approve(sm.ZevmAuth, sm.UniswapV2RouterAddr, big.NewInt(1e10))
if err != nil {
return err
}
receipt := utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
if receipt.Status == 0 {
return errors.New("approve failed")
}
Expand All @@ -150,7 +150,7 @@ func createZetaERC20LiquidityPool(sm *runner.E2ERunner) error {
if err != nil {
return err
}
receipt = utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
if receipt.Status == 0 {
return fmt.Errorf("add liquidity failed")
}
Expand All @@ -164,7 +164,7 @@ func sendInvalidUSDTDeposit(sm *runner.E2ERunner, amount *big.Int) (string, erro
if err != nil {
return "", err
}
receipt := utils2.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout)
sm.Logger.Info("USDT Approve receipt tx hash: %s", tx.Hash().Hex())

tx, err = sm.ERC20Custody.Deposit(
Expand All @@ -179,7 +179,7 @@ func sendInvalidUSDTDeposit(sm *runner.E2ERunner, amount *big.Int) (string, erro
}

sm.Logger.Info("GOERLI tx sent: %s; to %s, nonce %d", tx.Hash().String(), tx.To().Hex(), tx.Nonce())
receipt = utils2.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.GoerliClient, tx, sm.Logger, sm.ReceiptTimeout)
if receipt.Status == 0 {
return "", errors.New("expected the tx receipt to have status 1; got 0")
}
Expand Down
10 changes: 5 additions & 5 deletions e2e/e2etests/test_erc20_withdraw.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package e2etests

import (
"github.com/zeta-chain/zetacore/e2e/runner"
utils2 "github.com/zeta-chain/zetacore/e2e/utils"
"math/big"

ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
)

Expand All @@ -15,7 +15,7 @@ func TestERC20Withdraw(sm *runner.E2ERunner) {
if err != nil {
panic(err)
}
receipt := utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt := utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
if receipt.Status == 0 {
panic("approve failed")
}
Expand All @@ -26,7 +26,7 @@ func TestERC20Withdraw(sm *runner.E2ERunner) {
if err != nil {
panic(err)
}
receipt = utils2.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
receipt = utils.MustWaitForTxReceipt(sm.Ctx, sm.ZevmClient, tx, sm.Logger, sm.ReceiptTimeout)
sm.Logger.Info("Receipt txhash %s status %d", receipt.TxHash, receipt.Status)
for _, log := range receipt.Logs {
event, err := sm.USDTZRC20.ParseWithdrawal(*log)
Expand All @@ -43,7 +43,7 @@ func TestERC20Withdraw(sm *runner.E2ERunner) {
}

// verify the withdraw value
cctx := utils2.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout)
cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, receipt.TxHash.Hex(), sm.CctxClient, sm.Logger, sm.CctxTimeout)
verifyTransferAmountFromCCTX(sm, cctx, 1000)
}

Expand Down
Loading

0 comments on commit 678594f

Please sign in to comment.