From a6dade8421d1c147f71e2317225b9670fdcadbae Mon Sep 17 00:00:00 2001 From: forkfury Date: Tue, 9 Dec 2025 19:39:11 +0100 Subject: [PATCH] Update multisub_test.go --- event/multisub_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/event/multisub_test.go b/event/multisub_test.go index c92bcfae9b..bea104fe03 100644 --- a/event/multisub_test.go +++ b/event/multisub_test.go @@ -173,3 +173,30 @@ func TestMultisubFullUnsubscribe(t *testing.T) { default: } } + +func TestMultisubEmpty(t *testing.T) { + // Test that joining zero subscriptions doesn't block forever + sub := JoinSubscriptions() + if sub == nil { + t.Fatal("JoinSubscriptions() returned nil") + } + // Should be able to unsubscribe immediately without blocking + done := make(chan struct{}) + go func() { + sub.Unsubscribe() + close(done) + }() + select { + case <-done: + // Success - unsubscribe completed + case <-time.After(100 * time.Millisecond): + t.Error("Unsubscribe blocked on empty subscription list") + } + // Error channel should be closed + select { + case <-sub.Err(): + // Expected - channel is closed + default: + t.Error("error channel not closed after unsubscribe") + } +}