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.

33 lines
620 B

8 years ago
8 years ago
  1. package node
  2. import (
  3. "testing"
  4. "time"
  5. cfg "github.com/tendermint/tendermint/config"
  6. )
  7. func TestNodeStartStop(t *testing.T) {
  8. config := cfg.ResetTestRoot("node_node_test")
  9. // Create & start node
  10. n := NewNodeDefault(config)
  11. n.Start()
  12. log.Notice("Started node", "nodeInfo", n.sw.NodeInfo())
  13. // Wait a bit to initialize
  14. // TODO remove time.Sleep(), make asynchronous.
  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. }