[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.
This commit is contained in:
Zoltán Papp
2026-09-10 03:08:23 +02:00
parent f52a4cdbf0
commit 9aa573cc31
+3 -2
View File
@@ -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)
}
}