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
762 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. )
  8. func TestNodeStartStop(t *testing.T) {
  9. config := tendermint_test.ResetConfig("node_node_test")
  10. // Create & start node
  11. n := NewNodeDefault(config)
  12. protocol, address := ProtocolAndAddress(config.GetString("node_laddr"))
  13. l := p2p.NewDefaultListener(protocol, address, config.GetBool("skip_upnp"))
  14. n.AddListener(l)
  15. n.Start()
  16. log.Notice("Started node", "nodeInfo", n.sw.NodeInfo())
  17. time.Sleep(time.Second * 2)
  18. ch := make(chan struct{}, 1)
  19. go func() {
  20. n.Stop()
  21. ch <- struct{}{}
  22. }()
  23. ticker := time.NewTicker(time.Second * 5)
  24. select {
  25. case <-ch:
  26. case <-ticker.C:
  27. t.Fatal("timed out waiting for shutdown")
  28. }
  29. }