From b4e3d1a3386c36adb1272c5abc53ea4daa0d4b1d Mon Sep 17 00:00:00 2001 From: Guillermo Paoletti Date: Thu, 28 Oct 2021 13:50:21 +0200 Subject: [PATCH] tests: networking configuration fixed (#706) --- tests/e2e/integration_test.go | 4 +++- testutil/network/network.go | 37 +++++++++++++++++++++-------------- testutil/network/util.go | 13 +++++++----- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/tests/e2e/integration_test.go b/tests/e2e/integration_test.go index d2a5a01938..432f22957f 100644 --- a/tests/e2e/integration_test.go +++ b/tests/e2e/integration_test.go @@ -2,6 +2,7 @@ package e2e import ( "context" + "fmt" "math/big" "testing" @@ -40,7 +41,8 @@ func (s *IntegrationTestSuite) SetupSuite() { s.Require().NoError(err) if s.network.Validators[0].JSONRPCClient == nil { - s.network.Validators[0].JSONRPCClient, err = ethclient.Dial(s.network.Validators[0].JSONRPCAddress) + address := fmt.Sprintf("http://%s", s.network.Validators[0].AppConfig.JSONRPC.Address) + s.network.Validators[0].JSONRPCClient, err = ethclient.Dial(address) s.Require().NoError(err) } } diff --git a/testutil/network/network.go b/testutil/network/network.go index cd84e07feb..75246b4a89 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -159,21 +159,20 @@ type ( // a client can make RPC and API calls and interact with any client command // or handler. Validator struct { - AppConfig *config.Config - ClientCtx client.Context - Ctx *server.Context - Dir string - NodeID string - PubKey cryptotypes.PubKey - Moniker string - APIAddress string - RPCAddress string - P2PAddress string - JSONRPCAddress string - Address sdk.AccAddress - ValAddress sdk.ValAddress - RPCClient tmclient.Client - JSONRPCClient *ethclient.Client + AppConfig *config.Config + ClientCtx client.Context + Ctx *server.Context + Dir string + NodeID string + PubKey cryptotypes.PubKey + Moniker string + APIAddress string + RPCAddress string + P2PAddress string + Address sdk.AccAddress + ValAddress sdk.ValAddress + RPCClient tmclient.Client + JSONRPCClient *ethclient.Client tmNode *node.Node api *api.Server @@ -251,6 +250,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { appCfg.API.Enable = true appCfg.API.Swagger = false appCfg.Telemetry.Enabled = false + appCfg.Telemetry.GlobalLabels = [][]string{{"chain_id", cfg.ChainID}} ctx := server.NewDefaultContext() tmCfg := ctx.Config @@ -473,6 +473,13 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { srvconfig.SetConfigTemplate(customAppTemplate) srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appCfg) + ctx.Viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_")) + ctx.Viper.SetConfigFile(filepath.Join(nodeDir, "config/app.toml")) + err = ctx.Viper.ReadInConfig() + if err != nil { + return nil, err + } + clientCtx := client.Context{}. WithKeyringDir(clientDir). WithKeyring(kb). diff --git a/testutil/network/util.go b/testutil/network/util.go index 9c819546b1..4208c9e1ab 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -122,21 +122,24 @@ func startInProcess(cfg Config, val *Validator) error { } } - fmt.Println(val.Moniker, val.JSONRPCAddress, val.AppConfig.JSONRPC.Enable) - if val.AppConfig.JSONRPC.Enable && val.JSONRPCAddress != "" { + if val.AppConfig.JSONRPC.Enable && val.AppConfig.JSONRPC.Address != "" { if val.Ctx == nil || val.Ctx.Viper == nil { return fmt.Errorf("validator %s context is nil", val.Moniker) } tmEndpoint := "/websocket" - val.jsonrpc, val.jsonrpcDone, err = server.StartJSONRPC(val.Ctx, val.ClientCtx, val.JSONRPCAddress, tmEndpoint, *val.AppConfig) + tmRPCAddr := fmt.Sprintf("tcp://%s", val.AppConfig.GRPC.Address) + + val.jsonrpc, val.jsonrpcDone, err = server.StartJSONRPC(val.Ctx, val.ClientCtx, tmRPCAddr, tmEndpoint, *val.AppConfig) if err != nil { return err } - val.JSONRPCClient, err = ethclient.Dial(val.JSONRPCAddress) + address := fmt.Sprintf("http://%s", val.AppConfig.JSONRPC.Address) + + val.JSONRPCClient, err = ethclient.Dial(address) if err != nil { - return fmt.Errorf("failed to dial JSON-RPC at %s: %w", val.JSONRPCAddress, err) + return fmt.Errorf("failed to dial JSON-RPC at %s: %w", val.AppConfig.JSONRPC.Address, err) } }