|
@ -10,7 +10,6 @@ import ( |
|
|
"testing" |
|
|
"testing" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
"github.com/spf13/viper" |
|
|
|
|
|
"github.com/stretchr/testify/require" |
|
|
"github.com/stretchr/testify/require" |
|
|
logger "github.com/tendermint/tmlibs/logger" |
|
|
logger "github.com/tendermint/tmlibs/logger" |
|
|
|
|
|
|
|
@ -24,7 +23,7 @@ import ( |
|
|
"github.com/tendermint/tendermint/types" |
|
|
"github.com/tendermint/tendermint/types" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
var config *viper.Viper |
|
|
|
|
|
|
|
|
var config *nm.Config |
|
|
|
|
|
|
|
|
const tmLogLevel = "error" |
|
|
const tmLogLevel = "error" |
|
|
|
|
|
|
|
@ -54,40 +53,42 @@ func makeAddrs() (string, string, string) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// GetConfig returns a config for the test cases as a singleton
|
|
|
// GetConfig returns a config for the test cases as a singleton
|
|
|
func GetConfig() *viper.Viper { |
|
|
|
|
|
|
|
|
func GetConfig() *nm.Config { |
|
|
if config == nil { |
|
|
if config == nil { |
|
|
pathname := makePathname() |
|
|
pathname := makePathname() |
|
|
config = tendermint_test.ResetConfig(pathname) |
|
|
|
|
|
|
|
|
viperConfig := tendermint_test.ResetConfig(pathname) |
|
|
// Shut up the logging
|
|
|
// Shut up the logging
|
|
|
logger.SetLogLevel(tmLogLevel) |
|
|
logger.SetLogLevel(tmLogLevel) |
|
|
// and we use random ports to run in parallel
|
|
|
// and we use random ports to run in parallel
|
|
|
tm, rpc, grpc := makeAddrs() |
|
|
tm, rpc, grpc := makeAddrs() |
|
|
config.Set("node_laddr", tm) |
|
|
|
|
|
config.Set("rpc_laddr", rpc) |
|
|
|
|
|
config.Set("grpc_laddr", grpc) |
|
|
|
|
|
|
|
|
viperConfig.Set("p2p.laddr", tm) |
|
|
|
|
|
viperConfig.Set("rpc_laddr", rpc) |
|
|
|
|
|
viperConfig.Set("grpc_laddr", grpc) |
|
|
|
|
|
|
|
|
|
|
|
config = nm.ConfigFromViper(viperConfig) |
|
|
} |
|
|
} |
|
|
return config |
|
|
return config |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// GetURIClient gets a uri client pointing to the test tendermint rpc
|
|
|
// GetURIClient gets a uri client pointing to the test tendermint rpc
|
|
|
func GetURIClient() *client.URIClient { |
|
|
func GetURIClient() *client.URIClient { |
|
|
rpcAddr := GetConfig().GetString("rpc_laddr") |
|
|
|
|
|
|
|
|
rpcAddr := GetConfig().RPCListenAddress |
|
|
return client.NewURIClient(rpcAddr) |
|
|
return client.NewURIClient(rpcAddr) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// GetJSONClient gets a http/json client pointing to the test tendermint rpc
|
|
|
// GetJSONClient gets a http/json client pointing to the test tendermint rpc
|
|
|
func GetJSONClient() *client.JSONRPCClient { |
|
|
func GetJSONClient() *client.JSONRPCClient { |
|
|
rpcAddr := GetConfig().GetString("rpc_laddr") |
|
|
|
|
|
|
|
|
rpcAddr := GetConfig().RPCListenAddress |
|
|
return client.NewJSONRPCClient(rpcAddr) |
|
|
return client.NewJSONRPCClient(rpcAddr) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func GetGRPCClient() core_grpc.BroadcastAPIClient { |
|
|
func GetGRPCClient() core_grpc.BroadcastAPIClient { |
|
|
grpcAddr := config.GetString("grpc_laddr") |
|
|
|
|
|
|
|
|
grpcAddr := config.GRPCListenAddress |
|
|
return core_grpc.StartGRPCClient(grpcAddr) |
|
|
return core_grpc.StartGRPCClient(grpcAddr) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func GetWSClient() *client.WSClient { |
|
|
func GetWSClient() *client.WSClient { |
|
|
rpcAddr := GetConfig().GetString("rpc_laddr") |
|
|
|
|
|
|
|
|
rpcAddr := GetConfig().RPCListenAddress |
|
|
wsc := client.NewWSClient(rpcAddr, "/websocket") |
|
|
wsc := client.NewWSClient(rpcAddr, "/websocket") |
|
|
if _, err := wsc.Start(); err != nil { |
|
|
if _, err := wsc.Start(); err != nil { |
|
|
panic(err) |
|
|
panic(err) |
|
@ -107,7 +108,7 @@ func StartTendermint(app abci.Application) *nm.Node { |
|
|
func NewTendermint(app abci.Application) *nm.Node { |
|
|
func NewTendermint(app abci.Application) *nm.Node { |
|
|
// Create & start node
|
|
|
// Create & start node
|
|
|
config := GetConfig() |
|
|
config := GetConfig() |
|
|
privValidatorFile := config.GetString("priv_validator_file") |
|
|
|
|
|
|
|
|
privValidatorFile := config.PrivValidatorFile |
|
|
privValidator := types.LoadOrGenPrivValidator(privValidatorFile) |
|
|
privValidator := types.LoadOrGenPrivValidator(privValidatorFile) |
|
|
papp := proxy.NewLocalClientCreator(app) |
|
|
papp := proxy.NewLocalClientCreator(app) |
|
|
node := nm.NewNode(config, privValidator, papp) |
|
|
node := nm.NewNode(config, privValidator, papp) |
|
|