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.

40 lines
922 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 init() {
  10. tendermint_test.ResetConfig("node_node_test")
  11. }
  12. func TestNodeStartStop(t *testing.T) {
  13. // Get PrivValidator
  14. privValidatorFile := config.GetString("priv_validator_file")
  15. privValidator := types.LoadOrGenPrivValidator(privValidatorFile)
  16. // Create & start node
  17. n := NewNode(privValidator, GetProxyApp)
  18. l := p2p.NewDefaultListener("tcp", config.GetString("node_laddr"), config.GetBool("skip_upnp"))
  19. n.AddListener(l)
  20. n.Start()
  21. log.Notice("Started node", "nodeInfo", n.sw.NodeInfo())
  22. time.Sleep(time.Second * 2)
  23. ch := make(chan struct{}, 1)
  24. go func() {
  25. n.Stop()
  26. ch <- struct{}{}
  27. }()
  28. ticker := time.NewTicker(time.Second * 5)
  29. select {
  30. case <-ch:
  31. case <-ticker.C:
  32. t.Fatal("timed out waiting for shutdown")
  33. }
  34. }