mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-21 17:01:35 +00:00
add test for node start/stop (failing)
This commit is contained in:
36
node/node_test.go
Normal file
36
node/node_test.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package node
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
cfg "github.com/tendermint/tendermint/config"
|
||||||
|
tmcfg "github.com/tendermint/tendermint/config/tendermint"
|
||||||
|
"github.com/tendermint/tendermint/p2p"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
config := tmcfg.GetConfig("")
|
||||||
|
cfg.ApplyConfig(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNodeStartStop(t *testing.T) {
|
||||||
|
// Create & start node
|
||||||
|
n := NewNode()
|
||||||
|
l := p2p.NewDefaultListener("tcp", config.GetString("node_laddr"), false)
|
||||||
|
n.AddListener(l)
|
||||||
|
n.Start()
|
||||||
|
log.Notice("Started node", "nodeInfo", n.sw.NodeInfo())
|
||||||
|
time.Sleep(time.Second * 2)
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user