From cd9ee9d84b7f7daa678e42411ac31a0713f43230 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 22 Feb 2017 22:52:16 +0100 Subject: [PATCH] cleanup --- rpc/client/local/main_test.go | 11 ++++++----- rpc/client/local/rpc_test.go | 4 +--- rpc/test/helpers.go | 15 ++------------- rpc/test/main_test.go | 5 ++++- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/rpc/client/local/main_test.go b/rpc/client/local/main_test.go index 2a6930c38..5797843f6 100644 --- a/rpc/client/local/main_test.go +++ b/rpc/client/local/main_test.go @@ -5,17 +5,18 @@ import ( "testing" meapp "github.com/tendermint/merkleeyes/app" + nm "github.com/tendermint/tendermint/node" rpctest "github.com/tendermint/tendermint/rpc/test" ) +var node *nm.Node + func TestMain(m *testing.M) { - // start a tendermint node (and merkleeyes) in the background to test against + // configure a node, but don't start the server app := meapp.NewMerkleEyesApp("", 100) - node := rpctest.StartTendermint(app) - code := m.Run() + node = rpctest.StartTendermint(app) + code := m.Run() // and shut down proper at the end - node.Stop() - node.Wait() os.Exit(code) } diff --git a/rpc/client/local/rpc_test.go b/rpc/client/local/rpc_test.go index 1a5a38292..069db06f5 100644 --- a/rpc/client/local/rpc_test.go +++ b/rpc/client/local/rpc_test.go @@ -14,17 +14,15 @@ import ( // GetClient gets a rpc client pointing to the test tendermint rpc func GetClient() local.Client { - node := rpctest.GetNode() return local.New(node) } // Make sure status is correct (we connect properly) func TestStatus(t *testing.T) { c := GetClient() - chainID := rpctest.GetConfig().GetString("chain_id") status, err := c.Status() require.Nil(t, err, "%+v", err) - assert.Equal(t, chainID, status.NodeInfo.Network) + require.NotNil(t, status.PubKey) } // Make sure info is correct (we connect properly) diff --git a/rpc/test/helpers.go b/rpc/test/helpers.go index f51c83f9d..cf64ac155 100644 --- a/rpc/test/helpers.go +++ b/rpc/test/helpers.go @@ -26,7 +26,6 @@ import ( var ( config cfg.Config - node *nm.Node ) const tmLogLevel = "error" @@ -72,10 +71,6 @@ func GetConfig() cfg.Config { return config } -func GetNode() *nm.Node { - return node -} - // GetURIClient gets a uri client pointing to the test tendermint rpc func GetURIClient() *client.ClientURI { rpcAddr := GetConfig().GetString("rpc_laddr") @@ -103,12 +98,9 @@ func GetWSClient() *client.WSClient { } // StartTendermint starts a test tendermint server in a go routine and returns when it is initialized -// TODO: can one pass an Application in???? func StartTendermint(app abci.Application) *nm.Node { - // start a node - fmt.Println("Starting Tendermint...") - - node = NewTendermint(app) + node := NewTendermint(app) + node.Start() fmt.Println("Tendermint running!") return node } @@ -121,9 +113,6 @@ func NewTendermint(app abci.Application) *nm.Node { privValidator := types.LoadOrGenPrivValidator(privValidatorFile) papp := proxy.NewLocalClientCreator(app) node := nm.NewNode(config, privValidator, papp) - - // node.Start now does everything including the RPC server - node.Start() return node } diff --git a/rpc/test/main_test.go b/rpc/test/main_test.go index e78cd17a1..f95176d9b 100644 --- a/rpc/test/main_test.go +++ b/rpc/test/main_test.go @@ -18,12 +18,15 @@ import ( "testing" "github.com/tendermint/abci/example/dummy" + nm "github.com/tendermint/tendermint/node" ) +var node *nm.Node + func TestMain(m *testing.M) { // start a tendermint node (and merkleeyes) in the background to test against app := dummy.NewDummyApplication() - node := StartTendermint(app) + node = StartTendermint(app) code := m.Run() // and shut down proper at the end