fix: handle graceful control shutdown and reconnects

This commit is contained in:
zarazaex69
2026-05-17 18:35:05 +03:00
parent 9a2bbfd44e
commit c6c301c058
9 changed files with 256 additions and 33 deletions
+20
View File
@@ -124,6 +124,26 @@ func TestRunRejectsBadProtocolVersion(t *testing.T) {
}
}
func TestRunStopsOnPeerClose(t *testing.T) {
a, b := controlPair(t)
errCh := make(chan error, 1)
go func() {
errCh <- Run(context.Background(), a, Config{Interval: time.Hour})
}()
if err := SendClose(b); err != nil {
t.Fatalf("SendClose() error = %v", err)
}
select {
case err := <-errCh:
if !errors.Is(err, ErrClosedByPeer) {
t.Fatalf("Run() error = %v, want ErrClosedByPeer", err)
}
case <-time.After(time.Second):
t.Fatal("timed out waiting for peer close")
}
}
func TestReadFrameRejectsTooLarge(t *testing.T) {
a, b := controlPair(t)
go func() {