Skip to content

Commit 04e0129

Browse files
authored
fix: Stress test refactor (#1501)
* fixed local stress test * added new cmd to initialize config file. * cleaned up stress test cmd by using config file * add changelog * ran make generate * fix gosec error * update refactor, can remove the cmd from orchestrator later. * update refactor
1 parent dfc2314 commit 04e0129

File tree

9 files changed

+367
-649
lines changed

9 files changed

+367
-649
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Getting the correct TSS address for Bitcoin now requires proviidng the Bitcoin c
8181
* [1546](https://github.com/zeta-chain/node/pull/1546) - fix reset of pending nonces on genesis import
8282
* [1555](https://github.com/zeta-chain/node/pull/1555) - Reduce websocket message limit to 10MB
8383
* [1567](https://github.com/zeta-chain/node/pull/1567) - add bitcoin chain id to fetch the tss address rpc endpoint
84+
* [1501](https://github.com/zeta-chain/node/pull/1501) - fix stress test - use new refactored config file and smoketest runner
8485
* [1589](https://github.com/zeta-chain/node/pull/1589) - add bitcoin chain id to `get tss address` and `get tss address historical` cli query
8586

8687
### Refactoring

cmd/zetae2e/init.go

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/zeta-chain/zetacore/cmd/zetae2e/local"
7+
8+
"github.com/spf13/cobra"
9+
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/config"
10+
)
11+
12+
var initConf = config.Config{}
13+
var configFile = ""
14+
15+
func NewInitCmd() *cobra.Command {
16+
var InitCmd = &cobra.Command{
17+
Use: "init",
18+
Short: "initialize config file for e2e tests",
19+
Run: initConfig,
20+
}
21+
22+
InitCmd.Flags().StringVar(&initConf.RPCs.EVM, "ethURL", "http://eth:8545", "--ethURL http://eth:8545")
23+
InitCmd.Flags().StringVar(&initConf.RPCs.ZetaCoreGRPC, "grpcURL", "zetacore0:9090", "--grpcURL zetacore0:9090")
24+
InitCmd.Flags().StringVar(&initConf.RPCs.ZetaCoreRPC, "rpcURL", "http://zetacore0:26657", "--rpcURL http://zetacore0:26657")
25+
InitCmd.Flags().StringVar(&initConf.RPCs.Zevm, "zevmURL", "http://zetacore0:8545", "--zevmURL http://zetacore0:8545")
26+
InitCmd.Flags().StringVar(&initConf.RPCs.Bitcoin, "btcURL", "bitcoin:18443", "--grpcURL bitcoin:18443")
27+
28+
InitCmd.Flags().StringVar(&initConf.ZetaChainID, "chainID", "athens_101-1", "--chainID athens_101-1")
29+
InitCmd.Flags().StringVar(&configFile, local.FlagConfigFile, "smoketest.config", "--cfg ./smoketest.config")
30+
31+
return InitCmd
32+
}
33+
34+
func initConfig(_ *cobra.Command, _ []string) {
35+
err := config.WriteConfig(configFile, initConf)
36+
if err != nil {
37+
fmt.Printf("error writing config file: %s", err.Error())
38+
}
39+
}

cmd/zetae2e/local/local.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
const (
1919
flagContractsDeployed = "deployed"
2020
flagWaitForHeight = "wait-for"
21-
flagConfigFile = "config"
21+
FlagConfigFile = "config"
2222
flagVerbose = "verbose"
2323
flagTestAdmin = "test-admin"
2424
flagTestCustom = "test-custom"
@@ -51,7 +51,7 @@ func NewLocalCmd() *cobra.Command {
5151
"block height for tests to begin, ex. --wait-for 100",
5252
)
5353
cmd.Flags().String(
54-
flagConfigFile,
54+
FlagConfigFile,
5555
"",
5656
"config file to use for the tests",
5757
)
@@ -149,7 +149,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
149149
}()
150150

151151
// initialize tests config
152-
conf, err := getConfig(cmd)
152+
conf, err := GetConfig(cmd)
153153
if err != nil {
154154
panic(err)
155155
}

cmd/zetae2e/local/utils.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import (
1616
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
1717
)
1818

19-
// getConfig returns config from file from the command line flag
20-
func getConfig(cmd *cobra.Command) (config.Config, error) {
21-
configFile, err := cmd.Flags().GetString(flagConfigFile)
19+
// GetConfig returns config from file from the command line flag
20+
func GetConfig(cmd *cobra.Command) (config.Config, error) {
21+
configFile, err := cmd.Flags().GetString(FlagConfigFile)
2222
if err != nil {
2323
return config.Config{}, err
2424
}

cmd/zetae2e/root.go

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ func NewRootCmd() *cobra.Command {
1313
cmd.AddCommand(
1414
NewRunCmd(),
1515
local.NewLocalCmd(),
16+
NewStressTestCmd(),
17+
NewInitCmd(),
1618
)
1719

1820
return cmd

0 commit comments

Comments
 (0)