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
825 B

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. package peer
  2. import (
  3. . "github.com/tendermint/tendermint/binary"
  4. "testing"
  5. "time"
  6. )
  7. func TestLocalConnection(t *testing.T) {
  8. makePeer := func(conn *Connection) *Peer {
  9. bufferSize := 10
  10. p := &Peer{conn: conn}
  11. p.channels := map[String]*Channel{}
  12. p.channels["ch1"] = NewChannel("ch1", bufferSize)
  13. p.channels["ch2"] = NewChannel("ch2", bufferSize)
  14. return p
  15. }
  16. c1 := NewClient(makePeer)
  17. c2 := NewClient(makePeer)
  18. s1 := NewServer("tcp", "127.0.0.1:8001", c1)
  19. c2.ConnectTo(c1.LocalAddress())
  20. // lets send a message from c1 to c2.
  21. // XXX do we even want a broadcast function?
  22. c1.Broadcast(String(""), String("message"))
  23. time.Sleep(500 * time.Millisecond)
  24. inMsg := c2.PopMessage(String(""))
  25. c1.Stop()
  26. c2.Stop()
  27. }