-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(
e2e
): allow to run E2E tests on any networks (#1584)
* add new logger functionality * add eth withdraw tests * logger event parsing * simplify logs * add account command * add example config * add cctx wait in deposit tests * bitcoin config * lint * push back Ethereum tests * update config example * add report rendering * goimport * changelog * fix balance calculation and remove accounting * initialize bitcoin balance * remove btc balance * remove cmd/smoketest * change deposit value * some changes for btc * goimport * some tests for balances * fix bitcoin balance code * initialize bitcoin deposit test * some fixes for bitcoin setup * goimports * some renaming * start some work to support zeta out test on testnet * goimports * disable bitcoin balance * add donation test * add readme * replace hardcoded address for zeta in and out * fix erc20 deposit * fix bitcoin deposit for testnet * some renaming * implement list tests command * zeta withdraw * goimport * fix zeta withdraw * fix TestZetaWithdrawBTCRevert * add zeta deposit test * reorganize tests * add some more logs * improve logger concurrency * introduce stress tests * some proposal tests * add more proposal to test * add bitcoin stress tests * deposit stress tests * btc deposit stress tests * make generate * remove legacy get TSS * fix chain ID * fix chain ID
- Loading branch information
Showing
71 changed files
with
2,261 additions
and
1,522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
ethcommon "github.com/ethereum/go-ethereum/common" | ||
"github.com/fatih/color" | ||
"github.com/spf13/cobra" | ||
"github.com/zeta-chain/zetacore/app" | ||
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/config" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/runner" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/utils" | ||
) | ||
|
||
const flagSkipBTC = "skip-btc" | ||
|
||
// NewBalancesCmd returns the balances command | ||
// which shows from the key and rpc, the balance of the account on different network | ||
func NewBalancesCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "balances [config-file]", | ||
Short: "Show account balances on networks for E2E tests", | ||
RunE: runBalances, | ||
Args: cobra.ExactArgs(1), | ||
} | ||
cmd.Flags().Bool( | ||
flagSkipBTC, | ||
false, | ||
"skip the BTC network", | ||
) | ||
return cmd | ||
} | ||
|
||
func runBalances(cmd *cobra.Command, args []string) error { | ||
// read the config file | ||
conf, err := config.ReadConfig(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
skipBTC, err := cmd.Flags().GetBool(flagSkipBTC) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// initialize logger | ||
logger := runner.NewLogger(false, color.FgHiCyan, "") | ||
|
||
// set config | ||
app.SetConfig() | ||
|
||
// initialize context | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
|
||
// get EVM address from config | ||
evmAddr := conf.Accounts.EVMAddress | ||
if !ethcommon.IsHexAddress(evmAddr) { | ||
cancel() | ||
return errors.New("invalid EVM address") | ||
} | ||
|
||
// initialize deployer runner with config | ||
r, err := zetae2econfig.RunnerFromConfig( | ||
ctx, | ||
"e2e", | ||
cancel, | ||
conf, | ||
ethcommon.HexToAddress(evmAddr), | ||
conf.Accounts.EVMPrivKey, | ||
utils.FungibleAdminName, // placeholder value, not used | ||
FungibleAdminMnemonic, // placeholder value, not used | ||
logger, | ||
) | ||
if err != nil { | ||
cancel() | ||
return err | ||
} | ||
|
||
balances, err := r.GetAccountBalances(skipBTC) | ||
if err != nil { | ||
cancel() | ||
return err | ||
} | ||
r.PrintAccountBalances(balances) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
ethcommon "github.com/ethereum/go-ethereum/common" | ||
"github.com/fatih/color" | ||
"github.com/spf13/cobra" | ||
"github.com/zeta-chain/zetacore/app" | ||
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/config" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/runner" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/utils" | ||
) | ||
|
||
const flagPrivKey = "privkey" | ||
|
||
// NewBitcoinAddressCmd returns the bitcoin address command | ||
// which shows from the used config file, the bitcoin address that can be used to receive funds for the E2E tests | ||
func NewBitcoinAddressCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "bitcoin-address [config-file] ", | ||
Short: "Show Bitcoin address to receive funds for E2E tests", | ||
RunE: runBitcoinAddress, | ||
Args: cobra.ExactArgs(1), | ||
} | ||
cmd.Flags().Bool( | ||
flagPrivKey, | ||
false, | ||
"show the priv key in WIF format", | ||
) | ||
return cmd | ||
} | ||
|
||
func runBitcoinAddress(cmd *cobra.Command, args []string) error { | ||
showPrivKey, err := cmd.Flags().GetBool(flagPrivKey) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// read the config file | ||
conf, err := config.ReadConfig(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// initialize logger | ||
logger := runner.NewLogger(false, color.FgHiYellow, "") | ||
|
||
// set config | ||
app.SetConfig() | ||
|
||
// initialize context | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
|
||
// get EVM address from config | ||
evmAddr := conf.Accounts.EVMAddress | ||
if !ethcommon.IsHexAddress(evmAddr) { | ||
cancel() | ||
return errors.New("invalid EVM address") | ||
} | ||
|
||
// initialize deployer runner with config | ||
r, err := zetae2econfig.RunnerFromConfig( | ||
ctx, | ||
"e2e", | ||
cancel, | ||
conf, | ||
ethcommon.HexToAddress(evmAddr), | ||
conf.Accounts.EVMPrivKey, | ||
utils.FungibleAdminName, // placeholder value, not used | ||
FungibleAdminMnemonic, // placeholder value, not used | ||
logger, | ||
) | ||
if err != nil { | ||
cancel() | ||
return err | ||
} | ||
|
||
addr, privKey, err := r.GetBtcAddress() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
logger.Print("* BTC address: %s", addr) | ||
if showPrivKey { | ||
logger.Print("* BTC privkey: %s", privKey) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.