diff --git a/go/internal/delivery/helpers_test.go b/go/internal/delivery/helpers_test.go index 39ddfc147..00ad44b62 100644 --- a/go/internal/delivery/helpers_test.go +++ b/go/internal/delivery/helpers_test.go @@ -625,8 +625,9 @@ func (f *fakeReads) seedOwedMention(agent store.AccountID, channel store.Channel } // waitForOwed blocks until agent has exactly n owed-mention rows, or fails at the -// deadline — a polling barrier for the nil-waker case where no dispatch/wake -// signal is available to gate on (the owed row is the only observable effect). +// deadline — a polling barrier for cases where the owed-row count is the only +// observable effect to gate on, e.g. a nil-waker record (no dispatch/wake +// signal) or a start-edge sweep's ClearOwedMention (owed -> 0 after the sweep). func (f *fakeReads) waitForOwed(t *testing.T, agent store.AccountID, n int) { t.Helper() deadline := time.After(testTimeout) diff --git a/go/internal/delivery/offline_mention_test.go b/go/internal/delivery/offline_mention_test.go index d40092d6a..edf270a88 100644 --- a/go/internal/delivery/offline_mention_test.go +++ b/go/internal/delivery/offline_mention_test.go @@ -233,14 +233,14 @@ func TestUnreadableOwedMentionClearedNotReswept(t *testing.T) { startConsumer(t, c) c.OnSessionStarted("sess-recip", recipient) - c.waitStartsDrained(t) - + // The sweep's observable effect is the clear (owed -> 0); gate on it. A bare + // waitStartsDrained only proves the start edge was DEQUEUED, not that the + // sweep's ClearOwedMention ran (introspect_test.go), so asserting owedCount + // right after it races the async sweep and flakes red under CI load. + reads.waitForOwed(t, recipient, 0) if got := disp.snapshot(); len(got) != 0 { t.Fatalf("dispatches = %d, want 0 (an unreadable owed message is cleared, not dispatched)", len(got)) } - if n := reads.owedCount(recipient); n != 0 { - t.Fatalf("owed rows for recipient = %d, want 0 (the unreadable row must be cleared)", n) - } // A second start edge finds nothing owed — the row was cleared, so no re-log loop. c.OnSessionStarted("sess-recip", recipient)