From 799f041ae1d90c743b424e0fb95c89b369adea78 Mon Sep 17 00:00:00 2001 From: s7v7nislands Date: Fri, 11 Mar 2022 23:24:13 +0800 Subject: [PATCH] rpc: fix defer in test (#24490) Co-authored-by: Felix Lange --- rpc/server_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rpc/server_test.go b/rpc/server_test.go index c692a071cf..e67893710d 100644 --- a/rpc/server_test.go +++ b/rpc/server_test.go @@ -134,7 +134,7 @@ 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)) @@ -142,6 +142,8 @@ func TestServerShortLivedConn(t *testing.T) { // 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) }