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
33 changes: 27 additions & 6 deletions js/net/src/lite/widened_max_age.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// as stale, including those below where SUBSCRIBE_START resolved, and never one twice.

import { expect, test } from "bun:test";
import { Milli, now } from "@moq/clock";
import { Milli } from "@moq/clock";
import { accept, connect } from "../connection/index.ts";
import { hooks } from "../internal.ts";
import { createMockTransportPair } from "../mock.ts";
import { Producer as OriginProducer } from "../origin.ts";
import * as Path from "../path.ts";
Expand All @@ -25,6 +26,25 @@ async function received(reader: TrackSubscriber, count: number): Promise<bigint[
return got.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
}

/**
* Resolves once the publisher's re-drop of groups 1 and 2 reaches `reader`: the update clears
* their stale verdict, and the drop under the update's number sets it again. Each change is
* heard as it lands, so the clear is seen even when the re-drop follows it at once.
*/
function redropped(reader: TrackSubscriber): Promise<void> {
return new Promise((resolve) => {
let cleared = false;
const dispose = hooks.givenUp(reader, 1n).changed.subscribe(() => {
const held = hooks.staleHeld(reader, 1n, 3n);
if (held.length === 0) cleared = true;
else if (cleared && held.length === 1 && held[0].start === 1n && held[0].end === 3n) {
dispose();
resolve();
}
});
});
}

test("a widened maxDelay re-offers what the publisher skipped below the start", async () => {
const pair = createMockTransportPair(ALPN_07_WIP);
const origin = new OriginProducer();
Expand Down Expand Up @@ -193,14 +213,15 @@ test("an update keeping the budget drops the stale groups again on lite-07", asy
}
expect(await received(reader, 2)).toEqual([3n, 4n]);

// Only the priority changes: groups 1 and 2 are still stale, so they are dropped again.
reader.update({ priority: 5 });
const before = now();
// Only the priority changes (the budget is resent, since an update replaces it): groups 1 and 2 are still stale, so they are dropped again. The
// track ends only once that re-drop has reached the reader, so the end is a FIN, not a reset
// of the reply still writing; a missing re-drop fails here instead of waiting out the grace.
const reached = redropped(reader);
Comment thread
kixelated marked this conversation as resolved.
Resolved
reader.update({ priority: 5, delay: { max: Milli(1500) } });
await reached;
producer.finish();
producer.close();
expect(await reader.recvGroup()).toBeUndefined();
// Well inside the 1.5s grace a missing re-drop would wait out, in nanoseconds.
expect(now() - before).toBeLessThan(500_000_000);

reader.close();
remote.close();
Expand Down
1 change: 0 additions & 1 deletion quest/m0/test-flakes-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ Public API: none. Wire: none.

- [Fallback playback](/quest/m0/test-flakes-2/ietf22-fallback.md) - a browser viewer follows a fallback within the media lane's bound without dropping its session
- [js/net's bandwidth sampling test holds up under load](/quest/m0/test-flakes-2/bandwidth-sampling.md) - the sampling test counts ticks without racing the mocked clock, and its `test.skip` is removed
- [js/net's widened max-age re-drop test ends cleanly, not with a reset](/quest/m0/test-flakes-2/widened-max-age-reset.md) - the test finishes the track only after the re-drop reply arrives, so the end is a FIN, and drops its wall-clock assert
- [bench/relay.test.py's stream-transport test gets a port free for TCP and UDP](/quest/m0/test-flakes-2/relay-port-pair.md) - the test binds TCP and UDP to one number free in both, so parallel checks can't collide with it
- [js/net's compressed-frame cap test holds up under load](/quest/m0/test-flakes-2/compressed-frame-cap.md) - the cap is proven without a 32 MiB payload, and its `test.skip` is removed
- [js/net's lite-07 re-dropped re-offer test holds up under load](/quest/m0/test-flakes-2/redropped-reoffer.md) - update 3 is ordered before the re-offer opens by an event, not a yield count, and its `test.skip` is removed
Expand Down
35 changes: 0 additions & 35 deletions quest/m0/test-flakes-2/widened-max-age-reset.md

This file was deleted.