Skip to content

Commit

Permalink
rpc: fix defer in test (#24490)
Browse files Browse the repository at this point in the history
Co-authored-by: Felix Lange <fjl@twurst.com>
  • Loading branch information
2 people authored and qinglin89 committed Aug 22, 2022
1 parent 0e65495 commit 799f041
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rpc/server_test.go
Expand Up @@ -134,14 +134,16 @@ func TestServerShortLivedConn(t *testing.T) {
if err != nil {
t.Fatal("can't dial:", err)
}
defer conn.Close()

conn.SetDeadline(deadline)
// Write the request, then half-close the connection so the server stops reading.
conn.Write([]byte(request))
conn.(*net.TCPConn).CloseWrite()
// Now try to get the response.
buf := make([]byte, 2000)
n, err := conn.Read(buf)
conn.Close()

if err != nil {
t.Fatal("read error:", err)
}
Expand Down

0 comments on commit 799f041

Please sign in to comment.