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.

36 lines
847 B

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