mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
Update multisub_test.go
This commit is contained in:
parent
8026d6dbf1
commit
a6dade8421
1 changed files with 27 additions and 0 deletions
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue