Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
y3llowcake committed Sep 3, 2019
1 parent 4f34f86 commit 525bfca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion ssh/mempipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ type memTransport struct {
*sync.Cond
}

func (t *memTransport) ReadPacket() ([]byte, error) {
return t.readPacket()
}

func (t *memTransport) readPacket() ([]byte, error) {
t.Lock()
defer t.Unlock()
Expand Down Expand Up @@ -53,6 +57,10 @@ func (t *memTransport) Close() error {
return err
}

func (t *memTransport) WritePacket(p []byte) error {
return t.writePacket(p)
}

func (t *memTransport) writePacket(p []byte) error {
t.write.Lock()
defer t.write.Unlock()
Expand All @@ -66,7 +74,7 @@ func (t *memTransport) writePacket(p []byte) error {
return nil
}

func memPipe() (a, b packetConn) {
func memPipe() (a, b *memTransport) {
t1 := memTransport{}
t2 := memTransport{}
t1.write = &t2
Expand Down
6 changes: 3 additions & 3 deletions ssh/mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestMuxChannelOverflow(t *testing.T) {
marshalUint32(packet[5:], uint32(1))
packet[9] = 42

if err := writer.mux.conn.writePacket(packet); err != nil {
if err := writer.mux.conn.WritePacket(packet); err != nil {
t.Errorf("could not send packet")
}
if _, err := reader.SendRequest("hello", true, nil); err == nil {
Expand Down Expand Up @@ -432,7 +432,7 @@ func TestMuxInvalidRecord(t *testing.T) {
marshalUint32(packet[5:], 1)
packet[9] = 42

a.conn.writePacket(packet)
a.conn.WritePacket(packet)
go a.SendRequest("hello", false, nil)
// 'a' wrote an invalid packet, so 'b' has exited.
req, ok := <-b.incomingRequests
Expand Down Expand Up @@ -475,7 +475,7 @@ func TestMuxMaxPacketSize(t *testing.T) {
marshalUint32(packet[5:], uint32(len(large)))
packet[9] = 42

if err := a.mux.conn.writePacket(packet); err != nil {
if err := a.mux.conn.WritePacket(packet); err != nil {
t.Errorf("could not send packet")
}

Expand Down

0 comments on commit 525bfca

Please sign in to comment.