tendermint/node/node_test.go

34 lines
620 B
Go
Raw Normal View History

2015-07-21 15:15:40 -07:00
package node
import (
"testing"
"time"
2017-05-04 19:33:08 -07:00
cfg "github.com/tendermint/tendermint/config"
2015-07-21 15:15:40 -07:00
)
func TestNodeStartStop(t *testing.T) {
2017-05-04 19:33:08 -07:00
config := cfg.ResetTestRoot("node_node_test")
2015-12-01 20:12:01 -08:00
2015-07-21 15:15:40 -07:00
// Create & start node
n := NewNodeDefault(config)
2015-07-21 15:15:40 -07:00
n.Start()
log.Notice("Started node", "nodeInfo", n.sw.NodeInfo())
// Wait a bit to initialize
// TODO remove time.Sleep(), make asynchronous.
2015-07-21 15:15:40 -07:00
time.Sleep(time.Second * 2)
2015-07-21 15:15:40 -07:00
ch := make(chan struct{}, 1)
go func() {
n.Stop()
ch <- struct{}{}
}()
ticker := time.NewTicker(time.Second * 5)
select {
case <-ch:
case <-ticker.C:
t.Fatal("timed out waiting for shutdown")
}
}