tendermint/node/node_test.go

35 lines
687 B
Go
Raw Normal View History

2015-07-21 18:15:40 -04:00
package node
import (
"testing"
"time"
"github.com/tendermint/tendermint/config/tendermint_test"
2015-07-21 18:15:40 -04:00
)
func TestNodeStartStop(t *testing.T) {
2017-05-01 22:14:37 -04:00
viperConfig := tendermint_test.ResetConfig("node_node_test")
config := ConfigFromViper(viperConfig)
2015-12-01 20:12:01 -08:00
2015-07-21 18:15:40 -04:00
// Create & start node
n := NewNodeDefault(config)
2015-07-21 18:15:40 -04: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 18:15:40 -04:00
time.Sleep(time.Second * 2)
2015-07-21 18:15:40 -04: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")
}
}