Skip to content

Commit f3a29f3

Browse files
matt2eclaude
andcommitted
test(links): cover the five-minute recheck of a left public channel that stays unreadable
e607882 keeps a lookup that still admits a left public channel in `withheld`, so a mounted link rechecks it after five minutes. No test covered that branch. Putting back the old predicate, which keeps the channel out of `withheld` because its open metadata still answers `found`, passed the relay and conversation suites. With that predicate no recheck is ever scheduled, and the link stays unreadable until something else asks for a lookup. A fake-timer store test now leaves a public channel, mounts a link to it, and answers the lookup with no admission. It checks that the link still names the channel as `found` with `readable: false` and no `looking`, that nothing is looked up before five minutes, and that the store's own wake-up looks it up again at five minutes. When that lookup admits the channel, the link is readable again. The test fails with the old predicate and passes on the current code. No product change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Matt Toohey <[email protected]>
1 parent e1f123c commit f3a29f3

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎src/features/relay/channel-references.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,30 @@ it("names a public channel the viewer left, and looks it up until it is readable
199199
expect(h.pending).toHaveLength(0);
200200
});
201201

202+
it("rechecks a mounted link to a left public channel after five minutes while it stays unreadable", async () => {
203+
const h = await setup();
204+
h.emit([roster(relay, MINE, [], 1_700_000_001)]);
205+
await vi.waitFor(() => expect(h.channels.get?.(MINE)).toBeUndefined());
206+
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
207+
const link = renderHook(() => useChannelReference(h.channels, MINE));
208+
await flush();
209+
// The lookup still admits no reading of it.
210+
await h.lookup([MINE], []);
211+
expect(link.result.current).toMatchObject({
212+
state: "found",
213+
name: "mine",
214+
readable: false,
215+
});
216+
expect(link.result.current).not.toHaveProperty("looking");
217+
await h.advance(5 * 60_000 - 1);
218+
expect(h.pending).toHaveLength(0);
219+
// Nothing re-renders the link: the store's own wake-up rechecks it.
220+
await h.advance(1);
221+
await h.lookup([MINE], [open(MINE, "mine")]);
222+
expect(link.result.current).toMatchObject({ state: "found", name: "mine" });
223+
expect(link.result.current).not.toHaveProperty("readable");
224+
});
225+
202226
it("forgets withheld answers when the session cache is cleared", async () => {
203227
const h = await setup();
204228
h.channels.refer?.(SECRET);

0 commit comments

Comments
 (0)