packer/rpc: tests passing
This commit is contained in:
parent
61fd3f7333
commit
105e5f6a6d
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue