packer/rpc: tests passing

This commit is contained in:
Mitchell Hashimoto 2013-12-09 14:44:26 -08:00
parent 61fd3f7333
commit 105e5f6a6d
2 changed files with 27 additions and 3 deletions

View File

@ -1,9 +1,33 @@
package rpc
import (
"net"
"testing"
)
func testClient(t *testing.T, server *Server) *Client {
return nil
l, err := net.Listen("tcp", ":0")
if err != nil {
t.Fatalf("err: %s", err)
}
go func() {
conn, err := l.Accept()
if err != nil {
t.Fatalf("err: %s", err)
}
server.ServeConn(conn)
}()
clientConn, err := net.Dial("tcp", l.Addr().String())
if err != nil {
t.Fatalf("err: %s", err)
}
client, err := NewClient(clientConn)
if err != nil {
t.Fatalf("err: %s", err)
}
return client
}

View File

@ -34,8 +34,8 @@ func (s *Server) ServeConn(conn io.ReadWriteCloser) {
mux := NewMuxConn(conn)
defer mux.Close()
// Get stream ID 0, which we always use as the stream for serving
// our RPC server on.
// Accept a connection on stream ID 0, which is always used for
// normal client to server connections.
stream, err := mux.Accept(0)
if err != nil {
log.Printf("[ERR] Error retrieving stream for serving: %s", err)