mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 14:21:14 +00:00
3291 follow-up (#3323)
* changelog: use issue number instead of PR number * follow up to #3291 - rpc/test/helpers.go add StopTendermint(node) func - remove ensureDir(filepath.Dir(walFile), 0700) - mempool/mempool_test.go add type cleanupFunc func() * cmd/show_validator: wrap err to make it more clear
This commit is contained in:
@@ -13,14 +13,12 @@ var node *nm.Node
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// start a tendermint node (and kvstore) in the background to test against
|
||||
var cleanup func()
|
||||
app := kvstore.NewKVStoreApplication()
|
||||
node, cleanup = rpctest.StartTendermint(app)
|
||||
node = rpctest.StartTendermint(app)
|
||||
|
||||
code := m.Run()
|
||||
|
||||
// and shut down proper at the end
|
||||
node.Stop()
|
||||
node.Wait()
|
||||
cleanup()
|
||||
rpctest.StopTendermint(node)
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
@@ -15,13 +15,12 @@ import (
|
||||
func TestMain(m *testing.M) {
|
||||
// start a tendermint node in the background to test against
|
||||
app := kvstore.NewKVStoreApplication()
|
||||
node, cleanup := rpctest.StartTendermint(app)
|
||||
node := rpctest.StartTendermint(app)
|
||||
|
||||
code := m.Run()
|
||||
|
||||
// and shut down proper at the end
|
||||
node.Stop()
|
||||
node.Wait()
|
||||
cleanup()
|
||||
rpctest.StopTendermint(node)
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +100,8 @@ func GetGRPCClient() core_grpc.BroadcastAPIClient {
|
||||
}
|
||||
|
||||
// StartTendermint starts a test tendermint server in a go routine and returns when it is initialized
|
||||
func StartTendermint(app abci.Application) (*nm.Node, func()) {
|
||||
node, cleanup := NewTendermint(app)
|
||||
func StartTendermint(app abci.Application) *nm.Node {
|
||||
node := NewTendermint(app)
|
||||
err := node.Start()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -113,11 +113,19 @@ func StartTendermint(app abci.Application) (*nm.Node, func()) {
|
||||
|
||||
fmt.Println("Tendermint running!")
|
||||
|
||||
return node, cleanup
|
||||
return node
|
||||
}
|
||||
|
||||
// StopTendermint stops a test tendermint server, waits until it's stopped and
|
||||
// cleans up test/config files.
|
||||
func StopTendermint(node *nm.Node) {
|
||||
node.Stop()
|
||||
node.Wait()
|
||||
os.RemoveAll(node.Config().RootDir)
|
||||
}
|
||||
|
||||
// NewTendermint creates a new tendermint server and sleeps forever
|
||||
func NewTendermint(app abci.Application) (*nm.Node, func()) {
|
||||
func NewTendermint(app abci.Application) *nm.Node {
|
||||
// Create & start node
|
||||
config := GetConfig()
|
||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
|
||||
@@ -138,5 +146,5 @@ func NewTendermint(app abci.Application) (*nm.Node, func()) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node, func() { os.RemoveAll(config.RootDir) }
|
||||
return node
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user