-
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.
Merge branch 'develop' into fix-race-as-default-build
- Loading branch information
Showing
84 changed files
with
4,529 additions
and
1,995 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.