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.

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