-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(
smoke-test
): smoke test general improvements: optimize exe…
…cution, clean up outputs, introduce zetae2e CLI (#1438) * create logger type * replace printf with logger * fix logger * changelogs * improve setup methods * goimport * fix multiple deposits * some smoke tests optimizations * some tests * fix lint * change deployer address * simplify runner init * use const for test names * allow anther account to run smoke tests * fix runner setup * fix accounting * erc20 tests in a go routine * imports * fix lint and fix concurrency * improve logger * goimport * use errgroup and handle panic in routine * add tests for zeta in routine * add more info in panic logs * add ethers and bitcoin tests * comment out multiple deposit test * lint issue * gosec issue * add logs on test completion * fix Zeta test * add output for lint * replace panic with error for smoke test fail * comment out some tests * fix false positive * fix test swap setup * fix color * make token sending parallel * file for test types * fix some tests * add admin tests * optimize test execution * add flags for admin and custom test * set back genesis time * remove additional sleep * fix bitcoin test * remove commented code * some tests in the CI * set right values for btc timeout * change core params * add block header test * goimport * use context object * add header check in smoke test beggining * fix lint * initialize zeta2e2 cli * use zetae2e cli for tests * add padding in logger * test removing mount in dockerfile * increase cctx timeout * update workflow machine * update option order * fix typo * test unifying docker compose command * test new approach for logs * initialize run command * make generate * revert workflow config * run command * fix gas limit * add testnet test * remove headers * change some numbers * simplify WaitCctxsMinedByInTxHash logic * goimports * bring back header check * add custom timeout for cctx and receipts * disable header test and increase timeout * increase confirmation count * increase tickers * confirmation to 2 * accounting * lint timeout
- Loading branch information
Showing
84 changed files
with
4,531 additions
and
1,997 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
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,120 @@ | ||
package config | ||
|
||
import ( | ||
"context" | ||
|
||
"google.golang.org/grpc" | ||
|
||
"github.com/btcsuite/btcd/rpcclient" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"github.com/ethereum/go-ethereum/crypto" | ||
"github.com/ethereum/go-ethereum/ethclient" | ||
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/config" | ||
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" | ||
fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" | ||
observertypes "github.com/zeta-chain/zetacore/x/observer/types" | ||
) | ||
|
||
// getClientsFromConfig get clients from config | ||
func getClientsFromConfig(ctx context.Context, conf config.Config, evmPrivKey string) ( | ||
*rpcclient.Client, | ||
*ethclient.Client, | ||
*bind.TransactOpts, | ||
crosschaintypes.QueryClient, | ||
fungibletypes.QueryClient, | ||
authtypes.QueryClient, | ||
banktypes.QueryClient, | ||
observertypes.QueryClient, | ||
*ethclient.Client, | ||
*bind.TransactOpts, | ||
error, | ||
) { | ||
btcRPCClient, err := getBtcClient(conf.RPCs.Bitcoin) | ||
if err != nil { | ||
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err | ||
} | ||
goerliClient, goerliAuth, err := getEVMClient(ctx, conf.RPCs.EVM, evmPrivKey) | ||
if err != nil { | ||
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err | ||
} | ||
cctxClient, fungibleClient, authClient, bankClient, observerClient, err := getZetaClients(conf.RPCs.ZetaCoreGRPC) | ||
if err != nil { | ||
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err | ||
} | ||
zevmClient, zevmAuth, err := getEVMClient(ctx, conf.RPCs.Zevm, evmPrivKey) | ||
if err != nil { | ||
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err | ||
} | ||
return btcRPCClient, | ||
goerliClient, | ||
goerliAuth, | ||
cctxClient, | ||
fungibleClient, | ||
authClient, | ||
bankClient, | ||
observerClient, | ||
zevmClient, | ||
zevmAuth, | ||
nil | ||
} | ||
|
||
// getBtcClient get btc client | ||
func getBtcClient(rpc string) (*rpcclient.Client, error) { | ||
connCfg := &rpcclient.ConnConfig{ | ||
Host: rpc, | ||
User: "smoketest", | ||
Pass: "123", | ||
HTTPPostMode: true, | ||
DisableTLS: true, | ||
Params: "testnet3", | ||
} | ||
return rpcclient.New(connCfg, nil) | ||
} | ||
|
||
// getEVMClient get goerli client | ||
func getEVMClient(ctx context.Context, rpc, privKey string) (*ethclient.Client, *bind.TransactOpts, error) { | ||
evmClient, err := ethclient.Dial(rpc) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
chainid, err := evmClient.ChainID(ctx) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
deployerPrivkey, err := crypto.HexToECDSA(privKey) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
evmAuth, err := bind.NewKeyedTransactorWithChainID(deployerPrivkey, chainid) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
return evmClient, evmAuth, nil | ||
} | ||
|
||
// getZetaClients get zeta clients | ||
func getZetaClients(rpc string) ( | ||
crosschaintypes.QueryClient, | ||
fungibletypes.QueryClient, | ||
authtypes.QueryClient, | ||
banktypes.QueryClient, | ||
observertypes.QueryClient, | ||
error, | ||
) { | ||
grpcConn, err := grpc.Dial(rpc, grpc.WithInsecure()) | ||
if err != nil { | ||
return nil, nil, nil, nil, nil, err | ||
} | ||
|
||
cctxClient := crosschaintypes.NewQueryClient(grpcConn) | ||
fungibleClient := fungibletypes.NewQueryClient(grpcConn) | ||
authClient := authtypes.NewQueryClient(grpcConn) | ||
bankClient := banktypes.NewQueryClient(grpcConn) | ||
observerClient := observertypes.NewQueryClient(grpcConn) | ||
|
||
return cctxClient, fungibleClient, authClient, bankClient, observerClient, 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,76 @@ | ||
package config | ||
|
||
import ( | ||
"context" | ||
|
||
ethcommon "github.com/ethereum/go-ethereum/common" | ||
"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/txserver" | ||
) | ||
|
||
// RunnerFromConfig create test runner from config | ||
func RunnerFromConfig( | ||
ctx context.Context, | ||
name string, | ||
ctxCancel context.CancelFunc, | ||
conf config.Config, | ||
evmUserAddr ethcommon.Address, | ||
evmUserPrivKey string, | ||
zetaUserName string, | ||
zetaUserMnemonic string, | ||
logger *runner.Logger, | ||
) (*runner.SmokeTestRunner, error) { | ||
// initialize clients | ||
btcRPCClient, | ||
goerliClient, | ||
goerliAuth, | ||
cctxClient, | ||
fungibleClient, | ||
authClient, | ||
bankClient, | ||
observerClient, | ||
zevmClient, | ||
zevmAuth, | ||
err := getClientsFromConfig(ctx, conf, evmUserPrivKey) | ||
if err != nil { | ||
return nil, err | ||
} | ||
// initialize client to send messages to ZetaChain | ||
zetaTxServer, err := txserver.NewZetaTxServer( | ||
conf.RPCs.ZetaCoreRPC, | ||
[]string{zetaUserName}, | ||
[]string{zetaUserMnemonic}, | ||
conf.ZetaChainID, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// initialize smoke test runner | ||
sm := runner.NewSmokeTestRunner( | ||
ctx, | ||
name, | ||
ctxCancel, | ||
evmUserAddr, | ||
evmUserPrivKey, | ||
zetaUserMnemonic, | ||
goerliClient, | ||
zevmClient, | ||
cctxClient, | ||
zetaTxServer, | ||
fungibleClient, | ||
authClient, | ||
bankClient, | ||
observerClient, | ||
goerliAuth, | ||
zevmAuth, | ||
btcRPCClient, | ||
logger, | ||
) | ||
|
||
// set contracts | ||
err = setContractsFromConfig(sm, conf) | ||
|
||
return sm, err | ||
} |
Oops, something went wrong.