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.

44 lines
992 B

  1. package node
  2. import (
  3. "testing"
  4. "time"
  5. . "github.com/tendermint/go-common"
  6. "github.com/tendermint/go-p2p"
  7. _ "github.com/tendermint/tendermint/config/tendermint_test"
  8. "github.com/tendermint/tmsp/example/golang"
  9. "github.com/tendermint/tmsp/server"
  10. )
  11. func TestNodeStartStop(t *testing.T) {
  12. // Start a dummy app
  13. go func() {
  14. _, err := server.StartListener(config.GetString("proxy_app"), example.NewDummyApplication())
  15. if err != nil {
  16. Exit(err.Error())
  17. }
  18. }()
  19. // wait for the server
  20. time.Sleep(time.Second * 2)
  21. // Create & start node
  22. n := NewNode()
  23. l := p2p.NewDefaultListener("tcp", config.GetString("node_laddr"), config.GetBool("skip_upnp"))
  24. n.AddListener(l)
  25. n.Start()
  26. log.Notice("Started node", "nodeInfo", n.sw.NodeInfo())
  27. time.Sleep(time.Second * 2)
  28. ch := make(chan struct{}, 1)
  29. go func() {
  30. n.Stop()
  31. ch <- struct{}{}
  32. }()
  33. ticker := time.NewTicker(time.Second * 5)
  34. select {
  35. case <-ch:
  36. case <-ticker.C:
  37. t.Fatal("timed out waiting for shutdown")
  38. }
  39. }