Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions js/net/src/track.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { rescale } from "./rescale.ts";
import { Timescale, Timestamp } from "./time.ts";
import { authoredInfo, Subscription, Producer as TrackProducer } from "./track.ts";
import { unwanted } from "./util/demand.ts";
import { LIVE, rangesStart } from "./window.ts";

const enc = new TextEncoder();
const dec = new TextDecoder();
Expand Down Expand Up @@ -633,6 +634,30 @@ test("multiple subscriber options aggregate like Rust", async () => {
expect(await none).toBeUndefined();
});

// A reader without ranges reads from the oldest group, as Rust's `Range::oldest()` default does,
// so beside a history reader the union still reaches the history floor and below it. A reader that
// asks for the live edge alone keeps the history reader's floor as its own range.
test("a reader without ranges keeps a history reader's floor", () => {
const producer = new TrackProducer("test");
const history = producer.subscribe({ ranges: [{ start: { absolute: 5n }, end: { absolute: 9n } }] });
const plain = producer.subscribe();
expect(producer.subscription.peek()?.ranges).toEqual([{}]);
expect(rangesStart(producer.subscription.peek()?.ranges ?? [])).toBeUndefined();

plain.close();
history.close();

const other = new TrackProducer("test");
const kept = other.subscribe({ ranges: [{ start: { absolute: 5n }, end: { absolute: 9n } }] });
const live = other.subscribe({ ranges: [LIVE] });
expect(other.subscription.peek()?.ranges).toEqual([
{ start: { absolute: 5n }, end: { absolute: 9n } },
{ start: { relative: 0n } },
]);
live.close();
kept.close();
});

test("each reader reads only its own ranges, whatever the union asks for", () => {
const producer = new TrackProducer("test");
const sparse = producer.subscribe({
Expand Down
22 changes: 0 additions & 22 deletions quest/m1/live-history-demand.md

This file was deleted.