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.

38 lines
770 B

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