From 9aa573cc316443bbbf2985c9de559e7acd969eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Thu, 10 Sep 2026 03:08:23 +0200 Subject: [PATCH] [relay] Assert the local-close cancellation cause explicitly The local-close test only rejected ErrServerDisconnected, so it would also have passed for ErrPeerDisconnected or a bare context.Canceled. closeConn cancels with net.ErrClosed, so assert that. --- shared/relay/client/manager_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shared/relay/client/manager_test.go b/shared/relay/client/manager_test.go index d6b2e226a..4a7840dd7 100644 --- a/shared/relay/client/manager_test.go +++ b/shared/relay/client/manager_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "net" "net/netip" "testing" "time" @@ -535,7 +536,7 @@ func TestConnContextCauseOnLocalClose(t *testing.T) { t.Fatal("conn context was not cancelled after a local close") } - if cause := context.Cause(relayedConn.Context()); errors.Is(cause, ErrServerDisconnected) { - t.Errorf("local close must not be reported as a server disconnect, got: %v", cause) + if cause := context.Cause(relayedConn.Context()); !errors.Is(cause, net.ErrClosed) { + t.Errorf("unexpected cancellation cause after a local close: %v, want %v", cause, net.ErrClosed) } }