From bea48698f8a56b5d05f017f988378607318337f8 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 18 Nov 2026 17:02:01 -0800 Subject: [PATCH] test(net): wait for the widened range's SUBSCRIBE_UPDATE before checking the feed is pending The lite-07 update loop now measures the SUBSCRIBE's fields (an async encode) before it edits the ranges and declares the feed pending, so one reaction drain no longer reaches the declaration. Read the update off the request stream instead: it is written only after the declaration. Co-Authored-By: Claude Opus 5.5 --- js/net/src/lite/subscriber.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/net/src/lite/subscriber.test.ts b/js/net/src/lite/subscriber.test.ts index d04c0b1350..78aa961838 100644 --- a/js/net/src/lite/subscriber.test.ts +++ b/js/net/src/lite/subscriber.test.ts @@ -2858,15 +2858,21 @@ test("a widened range's SUBSCRIBE_STARTED resolves the feed's start", async () = await opened(0); await answerTrackInfo(streams[0], version); const request = await opened(1); + const sent = new Reader(request.outbound, undefined, version); + expect(await sent.u53()).toBe(StreamId.Subscribe); + await Subscribe.decode(sent, version); await request.reading; expect(hooks.sourceStart(track)).toBe("pending"); await respond(request, version, [{ start: new SubscribeStart([undefined]) }]); await drainReactions(); expect(hooks.sourceStart(track)).not.toBe("pending"); track.update({ ranges: [{ start: { time: 0n }, end: { time: 1n } }] }); - await drainReactions(); + // The feed goes pending before the update is written, so reading it waits for both. + const update = await SubscribeUpdate.decode(sent, version); expect(hooks.sourceStart(track)).toBe("pending"); - // The widened range took the next Range ID. + // The widened range retires Range ID 0 and takes the next one. + expect(update.remove).toEqual([0n]); + expect(update.ranges).toHaveLength(1); await respond(request, version, [{ started: new SubscribeStarted(1n, 1n) }]); await drainReactions(); expect(await track.start()).toBe(1n);