You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
619 B

  1. package node
  2. import (
  3. "testing"
  4. "time"
  5. _ "github.com/tendermint/tendermint/config/tendermint_test"
  6. "github.com/tendermint/tendermint/p2p"
  7. )
  8. func TestNodeStartStop(t *testing.T) {
  9. // Create & start node
  10. n := NewNode()
  11. l := p2p.NewDefaultListener("tcp", config.GetString("node_laddr"))
  12. n.AddListener(l)
  13. n.Start()
  14. log.Notice("Started node", "nodeInfo", n.sw.NodeInfo())
  15. time.Sleep(time.Second * 2)
  16. ch := make(chan struct{}, 1)
  17. go func() {
  18. n.Stop()
  19. ch <- struct{}{}
  20. }()
  21. ticker := time.NewTicker(time.Second * 5)
  22. select {
  23. case <-ch:
  24. case <-ticker.C:
  25. t.Fatal("timed out waiting for shutdown")
  26. }
  27. }