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
642 B

  1. package node
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/tendermint/tendermint/config/tendermint_test"
  6. )
  7. func TestNodeStartStop(t *testing.T) {
  8. config := tendermint_test.ResetConfig("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. }