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.

34 lines
664 B

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. package node
  2. import (
  3. "testing"
  4. "time"
  5. cfg "github.com/tendermint/tendermint/config"
  6. "github.com/tendermint/tmlibs/log"
  7. )
  8. func TestNodeStartStop(t *testing.T) {
  9. config := cfg.ResetTestRoot("node_node_test")
  10. // Create & start node
  11. n := NewNodeDefault(config, log.TestingLogger())
  12. n.Start()
  13. t.Logf("Started node %v", n.sw.NodeInfo())
  14. // Wait a bit to initialize
  15. // TODO remove time.Sleep(), make asynchronous.
  16. time.Sleep(time.Second * 2)
  17. ch := make(chan struct{}, 1)
  18. go func() {
  19. n.Stop()
  20. ch <- struct{}{}
  21. }()
  22. ticker := time.NewTicker(time.Second * 5)
  23. select {
  24. case <-ch:
  25. case <-ticker.C:
  26. t.Fatal("timed out waiting for shutdown")
  27. }
  28. }