mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-30 22:51:19 +00:00
cleanup
This commit is contained in:
parent
42a9b847ec
commit
cd9ee9d84b
@ -5,17 +5,18 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
meapp "github.com/tendermint/merkleeyes/app"
|
meapp "github.com/tendermint/merkleeyes/app"
|
||||||
|
nm "github.com/tendermint/tendermint/node"
|
||||||
rpctest "github.com/tendermint/tendermint/rpc/test"
|
rpctest "github.com/tendermint/tendermint/rpc/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
var node *nm.Node
|
||||||
// start a tendermint node (and merkleeyes) in the background to test against
|
|
||||||
app := meapp.NewMerkleEyesApp("", 100)
|
|
||||||
node := rpctest.StartTendermint(app)
|
|
||||||
code := m.Run()
|
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
// configure a node, but don't start the server
|
||||||
|
app := meapp.NewMerkleEyesApp("", 100)
|
||||||
|
node = rpctest.StartTendermint(app)
|
||||||
|
|
||||||
|
code := m.Run()
|
||||||
// and shut down proper at the end
|
// and shut down proper at the end
|
||||||
node.Stop()
|
|
||||||
node.Wait()
|
|
||||||
os.Exit(code)
|
os.Exit(code)
|
||||||
}
|
}
|
||||||
|
@ -14,17 +14,15 @@ import (
|
|||||||
|
|
||||||
// GetClient gets a rpc client pointing to the test tendermint rpc
|
// GetClient gets a rpc client pointing to the test tendermint rpc
|
||||||
func GetClient() local.Client {
|
func GetClient() local.Client {
|
||||||
node := rpctest.GetNode()
|
|
||||||
return local.New(node)
|
return local.New(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure status is correct (we connect properly)
|
// Make sure status is correct (we connect properly)
|
||||||
func TestStatus(t *testing.T) {
|
func TestStatus(t *testing.T) {
|
||||||
c := GetClient()
|
c := GetClient()
|
||||||
chainID := rpctest.GetConfig().GetString("chain_id")
|
|
||||||
status, err := c.Status()
|
status, err := c.Status()
|
||||||
require.Nil(t, err, "%+v", err)
|
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)
|
// Make sure info is correct (we connect properly)
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
config cfg.Config
|
config cfg.Config
|
||||||
node *nm.Node
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const tmLogLevel = "error"
|
const tmLogLevel = "error"
|
||||||
@ -72,10 +71,6 @@ func GetConfig() cfg.Config {
|
|||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetNode() *nm.Node {
|
|
||||||
return node
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.ClientURI {
|
func GetURIClient() *client.ClientURI {
|
||||||
rpcAddr := GetConfig().GetString("rpc_laddr")
|
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
|
// 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 {
|
func StartTendermint(app abci.Application) *nm.Node {
|
||||||
// start a node
|
node := NewTendermint(app)
|
||||||
fmt.Println("Starting Tendermint...")
|
node.Start()
|
||||||
|
|
||||||
node = NewTendermint(app)
|
|
||||||
fmt.Println("Tendermint running!")
|
fmt.Println("Tendermint running!")
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
@ -121,9 +113,6 @@ func NewTendermint(app abci.Application) *nm.Node {
|
|||||||
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)
|
||||||
|
|
||||||
// node.Start now does everything including the RPC server
|
|
||||||
node.Start()
|
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,15 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/tendermint/abci/example/dummy"
|
"github.com/tendermint/abci/example/dummy"
|
||||||
|
nm "github.com/tendermint/tendermint/node"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var node *nm.Node
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
// start a tendermint node (and merkleeyes) in the background to test against
|
// start a tendermint node (and merkleeyes) in the background to test against
|
||||||
app := dummy.NewDummyApplication()
|
app := dummy.NewDummyApplication()
|
||||||
node := StartTendermint(app)
|
node = StartTendermint(app)
|
||||||
code := m.Run()
|
code := m.Run()
|
||||||
|
|
||||||
// and shut down proper at the end
|
// and shut down proper at the end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user