diff --git a/internal/ipc/extra_test.go b/internal/ipc/extra_test.go index 2d82cbb..b758b1e 100644 --- a/internal/ipc/extra_test.go +++ b/internal/ipc/extra_test.go @@ -262,6 +262,24 @@ func TestBroadcastEvent_Delivery(t *testing.T) { } defer rawConn.Close() + // Wait until the server has tracked the connection before broadcasting, + // otherwise the event is sent to an empty set of connections. + ticker := time.NewTicker(5 * time.Millisecond) + defer ticker.Stop() + for { + srv.mu.Lock() + tracked := len(srv.conns) + srv.mu.Unlock() + if tracked > 0 { + break + } + select { + case <-ctx.Done(): + t.Fatal("timed out waiting for server to track connection") + case <-ticker.C: + } + } + // Broadcast an event. srv.BroadcastEvent(&ipcv1.Event{ Kind: &ipcv1.Event_IndexUpdated{IndexUpdated: &ipcv1.IndexUpdatedEvent{}},