diff --git a/cpp/obs/test/moq-audio-encoder-test.cpp b/cpp/obs/test/moq-audio-encoder-test.cpp index 77be01b1a86..361a37f1b90 100644 --- a/cpp/obs/test/moq-audio-encoder-test.cpp +++ b/cpp/obs/test/moq-audio-encoder-test.cpp @@ -308,15 +308,6 @@ int main() CHECK(g_info.type == OBS_ENCODER_AUDIO); // Hidden from OBS's encoder lists until Use MoQ encoders offers it. CHECK(g_info.caps & OBS_ENCODER_CAP_INTERNAL); - - { - obs_data defaults; - defaults.bitrate = 0; - defaults.preset.clear(); - g_info.get_defaults(&defaults); - CHECK(defaults.bitrate == 128); - CHECK(defaults.preset == "balanced"); - } printf("registers an internal Opus encoder: ok\n"); // OBS converts its mix to what the encoder asks for: 48 kHz interleaved float, diff --git a/dart/moq/test/moq_test.dart b/dart/moq/test/moq_test.dart index f958bb77b8b..5ac248316b0 100644 --- a/dart/moq/test/moq_test.dart +++ b/dart/moq/test/moq_test.dart @@ -43,11 +43,6 @@ void main() { other.close(); }); - test('diagnostic errors expose their named reason', () { - final error = TransportMoqException('reset'); - expect(error.reason, 'reset'); - }); - test('catalog handle closes with its broadcast', () { final broadcast = BroadcastProducer(); final catalog = moq_media.CatalogProducer(broadcast: broadcast); diff --git a/demo/carla/web/src/paths.test.ts b/demo/carla/web/src/paths.test.ts index 56da4345593..7d8c87c8b36 100644 --- a/demo/carla/web/src/paths.test.ts +++ b/demo/carla/web/src/paths.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { driverPath, parseCamera } from "./paths.ts"; +import { parseCamera } from "./paths.ts"; describe("parseCamera", () => { test("accepts exactly carla//.hang", () => { @@ -19,9 +19,3 @@ describe("parseCamera", () => { } }); }); - -describe("driverPath", () => { - test("roots every driver of a truck under viewer/carla/", () => { - expect(driverPath("truck1", "abc") as string).toBe("viewer/carla/truck1/abc"); - }); -}); diff --git a/demo/carla/web/src/truck.test.ts b/demo/carla/web/src/truck.test.ts index 2cd1905e793..9800aef2217 100644 --- a/demo/carla/web/src/truck.test.ts +++ b/demo/carla/web/src/truck.test.ts @@ -3,7 +3,7 @@ import * as Json from "@moq/json"; import * as Moq from "@moq/net"; import { applyKeys, REST } from "./input.ts"; import type { TruckStatus } from "./schemas.ts"; -import { nextGear, SafetyCommandBroadcast, shiftGear, Truck } from "./truck.ts"; +import { SafetyCommandBroadcast, shiftGear, Truck } from "./truck.ts"; describe("Truck video demand", () => { test("only hovered or focused cameras subscribe, and focus suppresses other previews", async () => { @@ -458,14 +458,6 @@ describe("Truck respawn", () => { }); }); -describe("nextGear", () => { - test("cycles N → F → R → N", () => { - expect(nextGear("neutral")).toBe("forward"); - expect(nextGear("forward")).toBe("reverse"); - expect(nextGear("reverse")).toBe("neutral"); - }); -}); - describe("shiftGear", () => { test("steps one gear at a time", () => { expect(shiftGear("neutral", 1)).toBe("forward"); diff --git a/go/wrapper/errors_test.go b/go/wrapper/errors_test.go index a68bd5307da..81684840d66 100644 --- a/go/wrapper/errors_test.go +++ b/go/wrapper/errors_test.go @@ -31,14 +31,6 @@ func TestStreamAbortProtocolDetails(t *testing.T) { } func TestErrorMessage(t *testing.T) { - var transport *ffi.MoqErrorTransport - if !errors.As(ffi.NewMoqErrorTransport("reset"), &transport) { - t.Fatal("transport payload is not accessible") - } - if transport.Reason != "reset" { - t.Fatalf("transport reason = %q, want reset", transport.Reason) - } - tests := []struct { err error want string diff --git a/go/wrapper/moq_test.go b/go/wrapper/moq_test.go index 60843a0c634..c46a30a4c7a 100644 --- a/go/wrapper/moq_test.go +++ b/go/wrapper/moq_test.go @@ -41,16 +41,6 @@ func opusHead() []byte { return buf } -func TestOriginLifecycle(t *testing.T) { - origin := newOrigin(t) - _ = origin.Consume() - dynamic, err := origin.Dynamic("") - if err != nil { - t.Fatal(err) - } - dynamic.Cancel() -} - func TestDynamicBroadcastRequest(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), testTimeout) defer cancel() diff --git a/js/auth/src/algorithm.test.ts b/js/auth/src/algorithm.test.ts index 386e11cb794..0d8df6e3d6b 100644 --- a/js/auth/src/algorithm.test.ts +++ b/js/auth/src/algorithm.test.ts @@ -1,27 +1,6 @@ import { expect, test } from "bun:test"; import { AlgorithmSchema } from "./algorithm.ts"; -test("algorithm schema - valid algorithms", () => { - const validAlgorithms = [ - "HS256", - "HS384", - "HS512", - "ES256", - "ES384", - "RS256", - "RS384", - "RS512", - "PS256", - "PS384", - "PS512", - "EdDSA", - ] as const; - - for (const alg of validAlgorithms) { - expect(AlgorithmSchema.parse(alg)).toBe(alg); - } -}); - test("algorithm schema - invalid algorithms", () => { expect(() => { AlgorithmSchema.parse("HS128"); @@ -40,28 +19,6 @@ test("algorithm schema - invalid algorithms", () => { }).toThrow(/Invalid option|Invalid input/); }); -test("algorithm schema - type safety", () => { - // Test that TypeScript types are working correctly - const validAlgorithm = AlgorithmSchema.parse("HS256"); - expect(typeof validAlgorithm === "string").toBeTruthy(); - expect( - [ - "HS256", - "HS384", - "HS512", - "ES256", - "ES384", - "RS256", - "RS384", - "RS512", - "PS256", - "PS384", - "PS512", - "EdDSA", - ].includes(validAlgorithm), - ).toBeTruthy(); -}); - test("algorithm schema - case sensitivity", () => { expect(() => { AlgorithmSchema.parse("hs256"); diff --git a/js/flate/src/codec.test.ts b/js/flate/src/codec.test.ts index add575702b4..ff4dad69d48 100644 --- a/js/flate/src/codec.test.ts +++ b/js/flate/src/codec.test.ts @@ -1,6 +1,6 @@ import { expect, test } from "bun:test"; import { Deflate, Inflate } from "fflate"; -import { DEFAULT_MAX_FRAME_SIZE, Decoder, Encoder } from "./codec.ts"; +import { Decoder, Encoder } from "./codec.ts"; const enc = new TextEncoder(); const dec = new TextDecoder(); @@ -72,10 +72,8 @@ test("codec rejects a frame that inflates past the cap", () => { expect(() => decoder.frame(slice)).toThrow(/exceeded 512/); }); -test("a decoder without options caps frames at 64 MiB", () => { +test("a decoder's frame cap cannot be lifted after construction", () => { const decoder = new Decoder(); - expect(DEFAULT_MAX_FRAME_SIZE).toBe(64 * 1024 * 1024); - expect(decoder.maxFrameSize).toBe(DEFAULT_MAX_FRAME_SIZE); expect(() => { (decoder as { maxFrameSize: number }).maxFrameSize = Infinity; }).toThrow(TypeError); diff --git a/js/hang/src/catalog/audio.test.ts b/js/hang/src/catalog/audio.test.ts index 6514eee8871..d35c5be4886 100644 --- a/js/hang/src/catalog/audio.test.ts +++ b/js/hang/src/catalog/audio.test.ts @@ -37,42 +37,6 @@ test("audio ranks known zero bitrate above unknown and breaks ties by code point expect(Catalog.Audio.ranked(renditions).map(([name]) => name)).toEqual(["\uE000", "\u{1F600}", "unknown"]); }); -test("pcm codec is accepted", () => { - const config = AudioConfigSchema.parse({ - codec: "pcm", - container: { kind: "legacy" }, - sampleRate: 48_000, - numberOfChannels: 2, - bitrate: 3_072_000, - }); - - expect(config.codec).toBe("pcm"); -}); - -test("audio config accepts a human-readable label", () => { - const config = AudioConfigSchema.parse({ - label: "English", - codec: "opus", - container: { kind: "legacy" }, - sampleRate: 48_000, - numberOfChannels: 2, - }); - - expect(config.label).toBe("English"); -}); - -test("audio config accepts optional enabled state", () => { - const config = AudioConfigSchema.parse({ - codec: "opus", - container: { kind: "legacy" }, - sampleRate: 48_000, - numberOfChannels: 2, - enabled: false, - }); - - expect(config.enabled).toBe(false); -}); - test("audio warmup round trips as optional integer milliseconds", () => { const base = { codec: "opus", container: { kind: "legacy" }, sampleRate: 48_000, numberOfChannels: 2 }; expect(AudioConfigSchema.parse(base).warmup).toBeUndefined(); diff --git a/js/hang/src/catalog/clock.test.ts b/js/hang/src/catalog/clock.test.ts index c9d377e5ff8..36d3fd60841 100644 --- a/js/hang/src/catalog/clock.test.ts +++ b/js/hang/src/catalog/clock.test.ts @@ -1,5 +1,5 @@ import { expect, test } from "bun:test"; -import { ClockSchema, MOQ_EPOCH_UNIX_MILLIS, u53, wallClockTime } from "./index.ts"; +import { ClockSchema, MOQ_EPOCH_UNIX_MILLIS, wallClockTime } from "./index.ts"; import { RootSchema } from "./root.ts"; // Mirrors rs/hang/fixtures/catalog-clock.json: the canonical new shape, a root clock plus an @@ -20,9 +20,8 @@ const FIXTURE = { archive: { timelines: { video: { track: "video.timeline.z", duration: 2000 } }, timescale: 1000 }, }; -test("timescale defaults to microseconds", () => { - const parsed = ClockSchema.parse({ wall: 1000 }); - expect(parsed.timescale).toBe(u53(1_000_000)); +test("an omitted timescale means microseconds on the wire", () => { + expect(Number(ClockSchema.parse({ wall: 1000 }).timescale)).toBe(1_000_000); }); test("a zero timescale is refused", () => { diff --git a/js/hang/src/catalog/data.test.ts b/js/hang/src/catalog/data.test.ts index dc2003997c4..bd6c1533d53 100644 --- a/js/hang/src/catalog/data.test.ts +++ b/js/hang/src/catalog/data.test.ts @@ -63,12 +63,6 @@ test("an unrecognized mode or compression survives verbatim", () => { expect(compressionSupported(future?.compression ?? "")).toBe(false); }); -test("the known modes and compressions are recognized", () => { - expect(modeSupported("snapshot")).toBe(true); - expect(modeSupported("stream")).toBe(true); - expect(compressionSupported("deflate")).toBe(true); -}); - test("fields belonging to an unrecognized mode survive a round trip", () => { // Preserving the mode string alone is not enough: a future mode comes with fields describing it, // and a relay that reparsed and republished would otherwise strip them, leaving an entry nothing diff --git a/js/hang/src/catalog/video.test.ts b/js/hang/src/catalog/video.test.ts index db73a89841d..8f80a4c0d68 100644 --- a/js/hang/src/catalog/video.test.ts +++ b/js/hang/src/catalog/video.test.ts @@ -99,17 +99,6 @@ test("video config accepts canonical display aspect fields", () => { expect("displayRatioHeight" in parsed).toBe(false); }); -test("video config accepts optional enabled state", () => { - const active = VideoConfigSchema.parse({ - codec: "avc1.64001f", - container: { kind: "legacy" }, - }); - const disabled = VideoConfigSchema.parse({ ...active, enabled: false }); - - expect(active.enabled).toBeUndefined(); - expect(disabled.enabled).toBe(false); -}); - test("video config ignores a legacy stalled flag", () => { const parsed = VideoConfigSchema.parse({ codec: "avc1.64001f", @@ -121,16 +110,6 @@ test("video config ignores a legacy stalled flag", () => { expect(parsed.enabled).toBeUndefined(); }); -test("video config accepts a human-readable label", () => { - const config = VideoConfigSchema.parse({ - label: "Main camera", - codec: "vp8", - container: { kind: "legacy" }, - }); - - expect(config.label).toBe("Main camera"); -}); - test("legacy video arrays derive display size from display aspect fields", () => { const parsed = VideoSchema.parse([ { diff --git a/js/hang/src/stats.test.ts b/js/hang/src/stats.test.ts index 221fff8b9bb..05efe31ebf6 100644 --- a/js/hang/src/stats.test.ts +++ b/js/hang/src/stats.test.ts @@ -82,8 +82,7 @@ test("shared invalid counters refuse instead of rounding", async () => { }); test("feedback discovery agrees with the Rust fixed track and final path suffix", () => { - expect(Echo.TRACK).toBe("feedback.json"); - expect(Echo.SUFFIX).toBe(".echo"); + expect({ track: Echo.TRACK, suffix: Echo.SUFFIX }).toEqual({ track: "feedback.json", suffix: ".echo" }); expect(Echo.isEcho(Path.from("room/alice.echo"))).toBe(true); expect(Echo.isEcho(Path.from("room.echo/alice"))).toBe(false); expect(Echo.isEcho(Path.from("room/alice.echoes"))).toBe(false); diff --git a/js/hang/src/util/opus.test.ts b/js/hang/src/util/opus.test.ts index 50f054aa879..5d58685fc97 100644 --- a/js/hang/src/util/opus.test.ts +++ b/js/hang/src/util/opus.test.ts @@ -33,12 +33,6 @@ describe("supportsRate", () => { expect(supportsRate(44100)).toBe(false); expect(supportsRate(22050)).toBe(false); }); - - it("accepts the native rates", () => { - for (const rate of SAMPLE_RATES) { - expect(supportsRate(rate)).toBe(true); - } - }); }); describe("toDOps", () => { diff --git a/js/json/src/snapshot/encoder.ts b/js/json/src/snapshot/encoder.ts index f42ec058142..cf0fe652978 100644 --- a/js/json/src/snapshot/encoder.ts +++ b/js/json/src/snapshot/encoder.ts @@ -13,10 +13,6 @@ const MAX_DELTA_FRAMES = 256; // entrypoint: the Producer needs it to know whether to hold a group open, nothing else does. export const DEFAULT_DELTA_RATIO = 8; -// Bytes a group may hold before it rolls when {@link Config.maxGroupBytes} is left unset: moq-net's -// per-group cache limit. Not re-exported from the package entrypoint; a test pins it to that limit. -export const DEFAULT_MAX_GROUP_BYTES = Group.MAX_GROUP_CACHE_BYTES; - /** Options shared by an {@link Encoder} and the {@link Producer} that wraps one. */ export interface Config { // Controls how aggressively the encoder emits deltas (merge patches) instead of full snapshots. @@ -153,7 +149,7 @@ export class Encoder { constructor(config: Config = {}) { this.#config = config; this.#compress = isDeflate(config.compression); - this.#maxGroupBytes = config.maxGroupBytes ?? DEFAULT_MAX_GROUP_BYTES; + this.#maxGroupBytes = config.maxGroupBytes ?? Group.MAX_GROUP_CACHE_BYTES; } /** diff --git a/js/json/src/snapshot/snapshot.test.ts b/js/json/src/snapshot/snapshot.test.ts index 2b513b922d8..34431979ab8 100644 --- a/js/json/src/snapshot/snapshot.test.ts +++ b/js/json/src/snapshot/snapshot.test.ts @@ -2,7 +2,7 @@ import { expect, test } from "bun:test"; import { Milli } from "@moq/clock"; import { Group, Error as NetError, StreamCode, Time, Track } from "@moq/net"; import { Consumer } from "./consumer.ts"; -import { DEFAULT_MAX_GROUP_BYTES, Encoder } from "./encoder.ts"; +import { Encoder } from "./encoder.ts"; import { Producer } from "./producer.ts"; type Value = Record; @@ -376,11 +376,6 @@ test("a rejected update leaves the previous value readable", async () => { expect(await drain(track.subscribe())).toEqual([{ keep: true }]); }); -test("the default group budget is moq-net's group cache limit", () => { - // The tests below shrink the budget, so pin the default they stand in for. - expect(DEFAULT_MAX_GROUP_BYTES).toBe(Group.MAX_GROUP_CACHE_BYTES); -}); - test("a delta that would overflow the snapshot rolls a new one instead", async () => { // A delta is only readable while its group still holds the snapshot it applies to. A patch // that pushes the group past the budget would abort it, leaving a late subscriber with no diff --git a/js/net/src/connection/cert.test.ts b/js/net/src/connection/cert.test.ts index c7dbb62f297..29cde611148 100644 --- a/js/net/src/connection/cert.test.ts +++ b/js/net/src/connection/cert.test.ts @@ -35,7 +35,3 @@ test("certificateHash rejects repeated BEGIN lines in linear time", async () => const pem = "-----BEGIN CERTIFICATE-----a".repeat(40_000); await expect(certificateHash(pem)).rejects.toThrow(/armor/); }); - -test("hex round-trips through fromBytes/toBytes", () => { - expect(Hex.fromBytes(Hex.toBytes(ABC_SHA256))).toBe(ABC_SHA256); -}); diff --git a/js/net/src/connection/extensions.test.ts b/js/net/src/connection/extensions.test.ts index 84897c4aac1..24ac0d1c476 100644 --- a/js/net/src/connection/extensions.test.ts +++ b/js/net/src/connection/extensions.test.ts @@ -34,11 +34,6 @@ async function acceptWith(extensions: Extensions) { return { pair, peer, connection }; } -test("every extension is offered by default", () => { - expect(offered()).toEqual({ auth: true, solicit: true, epoch: true }); - expect(offered({ solicit: false })).toEqual({ auth: true, solicit: false, epoch: true }); -}); - test("a declined extension stays out of SETUP", async () => { // Control: both sides offer both. const all = await handshake({}, {}); diff --git a/js/net/src/connection/reload.test.ts b/js/net/src/connection/reload.test.ts index 65f6a3bf4a9..06892bb4885 100644 --- a/js/net/src/connection/reload.test.ts +++ b/js/net/src/connection/reload.test.ts @@ -28,22 +28,6 @@ async function settle() { await new Promise((resolve) => setTimeout(resolve, 0)); } -test("enabled defaults to true", () => { - const omitted = new Reload(); - const explicitUndefined = new Reload({ enabled: undefined }); - const disabled = new Reload({ enabled: false }); - - try { - expect(omitted.enabled.peek()).toBe(true); - expect(explicitUndefined.enabled.peek()).toBe(true); - expect(disabled.enabled.peek()).toBe(false); - } finally { - omitted.close(); - explicitUndefined.close(); - disabled.close(); - } -}); - test("equivalent URL instances do not restart a pending connection", async () => { const original = globalThis.WebTransport; let connects = 0; diff --git a/js/net/src/error.test.ts b/js/net/src/error.test.ts index 143870469c8..6c071bdd58f 100644 --- a/js/net/src/error.test.ts +++ b/js/net/src/error.test.ts @@ -94,7 +94,6 @@ test("the error type names the registry the code came from", () => { }); test("invalid request IDs keep their session registry code", () => { - expect(Number(SessionCode.InvalidRequestId)).toBe(0x4); expect(fromClose({ closeCode: 0x4 })?.code).toBe(SessionCode.InvalidRequestId); }); @@ -207,23 +206,52 @@ test("fromClose: a clean close is null, a coded close keeps its code", () => { expect(fromClose({ closeCode: SessionCode.GoawayTimeout })?.message).toBe("remote error: 16"); }); -// The two registries are wire contracts (draft-lcurley-moq-lite, Error Codes) and must match -// the Rust tables, since the two implementations talk to each other. -test("the code tables match the spec", () => { - // moq-transport's, reused unchanged. - expect(Number(SessionCode.Cancel)).toBe(0x0); - expect(Number(SessionCode.Unauthorized)).toBe(0x2); - expect(Number(SessionCode.GoawayTimeout)).toBe(0x10); - expect(Number(SessionCode.AuthTokenCacheOverflow)).toBe(0x13); - expect(Number(SessionCode.Version)).toBe(0x15); - expect(Number(SessionCode.UnknownAuthTokenAlias)).toBe(0x17); - expect(Number(SessionCode.InvalidPath)).toBe(0x8); - expect(Number(SessionCode.InvalidAuthority)).toBe(0x19); - expect(Number(SessionCode.TooManyRequestUpdates)).toBe(0x1b); - expect(Number(StreamCode.Cancel)).toBe(0x1); - expect(Number(StreamCode.SessionClosed)).toBe(0x3); - expect(Number(StreamCode.TooFarBehind)).toBe(0x5); +// The two registries are wire contracts (draft-lcurley-moq-lite, Error Codes). Encoder and +// decoder share these constants, so only a spec table catches a renumbering. +test("session codes match the draft's Session Error Codes table", () => { + expect({ ...SessionCode } as Record).toEqual({ + Cancel: 0x0, + Internal: 0x1, + Unauthorized: 0x2, + ProtocolViolation: 0x3, + InvalidRequestId: 0x4, + KeyValueFormatting: 0x6, + TooManyRequests: 0x7, + InvalidPath: 0x8, + GoawayTimeout: 0x10, + Timeout: 0x11, + AuthTokenCacheOverflow: 0x13, + Version: 0x15, + UnknownAuthTokenAlias: 0x17, + Expired: 0x18, + InvalidAuthority: 0x19, + TooManyRequestUpdates: 0x1b, + Unsupported: 0x30, + }); +}); + +test("stream codes match the draft's Stream Error Codes table", () => { + expect({ ...StreamCode } as Record).toEqual({ + Internal: 0x0, + Cancel: 0x1, + DeliveryTimeout: 0x2, + SessionClosed: 0x3, + GoingAway: 0x4, + TooFarBehind: 0x5, + MalformedTrack: 0x12, + ControlTimeout: 0x31, + GroupTooLarge: 0x32, + NotFound: 0x33, + Old: 0x34, + Evicted: 0x35, + Unroutable: 0x36, + FrameTooLarge: 0x38, + TimestampMismatch: 0x39, + Unauthorized: 0x3b, + }); +}); +test("the code tables keep their registry ranges", () => { // Session codes retain moq-transport assignments below 32; Lite owns 48-63. for (const code of Object.values(SessionCode)) { if (code === SessionCode.Unsupported) { @@ -233,7 +261,6 @@ test("the code tables match the spec", () => { expect(code).toBeLessThan(32); } } - expect(Number(SessionCode.Unsupported)).toBe(0x30); // The stream table adds moq-lite's own 48-63 assignments. 32-47 is reserved and // carries nothing, so no code sits there. @@ -256,20 +283,8 @@ test("the code tables match the spec", () => { expect(code).toBeLessThan(32); } } - // The values the Rust `StreamError` sends for the same conditions. - expect(Number(StreamCode.ControlTimeout)).toBe(0x31); - expect(Number(StreamCode.GroupTooLarge)).toBe(0x32); - expect(Number(StreamCode.NotFound)).toBe(0x33); - expect(Number(StreamCode.Old)).toBe(0x34); - expect(Number(StreamCode.Evicted)).toBe(0x35); - expect(Number(StreamCode.Unroutable)).toBe(0x36); - expect(Number(StreamCode.FrameTooLarge)).toBe(0x38); - expect(Number(StreamCode.TimestampMismatch)).toBe(0x39); - expect(Number(StreamCode.Unauthorized)).toBe(0x3b); - // The spaces are disjoint: 0 ends a session cleanly but fails a stream. expect(Number(SessionCode.Cancel)).not.toBe(Number(StreamCode.Cancel)); - expect(Number(StreamCode.Internal)).toBe(0x0); }); test("fromTransport: decodes a real qmux stream reset", () => { diff --git a/js/net/src/ietf/cluster.test.ts b/js/net/src/ietf/cluster.test.ts index 85aadcec338..70a435fd6bc 100644 --- a/js/net/src/ietf/cluster.test.ts +++ b/js/net/src/ietf/cluster.test.ts @@ -62,16 +62,6 @@ function reader(bytes: Uint8Array, version: IetfVersion = VERSION): Reader { return new Reader(undefined, bytes, version); } -test("Cluster: the registry code points and their parity", () => { - // Other implementations key on these, so a typo is invisible against ourselves and - // fatal against anyone else. The parity is load-bearing too: odd values are - // length-prefixed byte strings, even ones bare varints. - expect(SetupOption.HopId).toBe(0x40b54n); - expect(SetupOption.RelayCost).toBe(0x40b56n); - expect(SetupOption.HopId % 2n).toBe(0n); - expect(SetupOption.RelayCost % 2n).toBe(0n); -}); - test("Cluster: the hop path carries no count of its own", async () => { // The entries fill the parameter length; a count would make us unreadable to every // other implementation. diff --git a/js/net/src/ietf/epoch.test.ts b/js/net/src/ietf/epoch.test.ts index 1c5f643a043..6f8c1a26290 100644 --- a/js/net/src/ietf/epoch.test.ts +++ b/js/net/src/ietf/epoch.test.ts @@ -67,13 +67,6 @@ function epochParam(value: Uint8Array): Parameters { return params; } -test("Epoch: the registry code points and their parity", () => { - // Odd values are length-prefixed byte strings, even ones bare varints. - expect(SetupOption.Epoch).toBe(0x40b68n); - expect(SetupOption.Epoch % 2n).toBe(0n); - expect(EPOCH_PARAM % 2n).toBe(1n); -}); - test("Epoch: SETUP declares it on draft-17 and later only", async () => { for (const version of LEGACY) { const params = new SetupOptions(); diff --git a/js/net/src/ietf/ietf.test.ts b/js/net/src/ietf/ietf.test.ts index 475f3fe4447..e3231756f45 100644 --- a/js/net/src/ietf/ietf.test.ts +++ b/js/net/src/ietf/ietf.test.ts @@ -1544,10 +1544,12 @@ test("Parameters v18 wire is identical to v17 (no count prefix, delta encoded ke expect(Array.from(await v18)).toEqual(Array.from(await v17)); }); -test("SubscribeNamespace: message IDs", () => { - // 0x11 through draft-17 (legacy), renumbered to 0x50 in draft-18 (#1542). - expect(SubscribeNamespace.SubscribeNamespaceLegacy.id).toBe(0x11); - expect(SubscribeNamespace.SubscribeNamespace.id).toBe(0x50); +test("SubscribeNamespace: message IDs match the draft registries", () => { + // 0x11 through draft-17, renumbered to 0x50 in draft-18. + expect({ + legacy: SubscribeNamespace.SubscribeNamespaceLegacy.id, + current: SubscribeNamespace.SubscribeNamespace.id, + }).toEqual({ legacy: 0x11, current: 0x50 }); }); test("SubscribeNamespace: decode rejects the wrong draft version", async () => { diff --git a/js/net/src/ietf/setup_options.test.ts b/js/net/src/ietf/setup_options.test.ts new file mode 100644 index 00000000000..e204369cf13 --- /dev/null +++ b/js/net/src/ietf/setup_options.test.ts @@ -0,0 +1,23 @@ +import { expect, test } from "bun:test"; +import { SetupOption } from "./setup_options.ts"; + +// Encoder and decoder share these keys, so only a spec table catches a renumbering. The +// extension keys come from each draft-lcurley-moq-* IANA section; even keys are bare varints. +test("setup option keys match the registries", () => { + expect({ ...SetupOption }).toEqual({ + Path: 0x01n, + MaxRequestId: 0x02n, + AuthorizationToken: 0x03n, + MaxAuthTokenCacheSize: 0x04n, + Authority: 0x05n, + Implementation: 0x07n, + HopId: 0x40b54n, + RelayCost: 0x40b56n, + Solicit: 0x40b5an, + Hidden: 0x40b5cn, + MaxAge: 0x915c4n, + Auth: 0x40b60n, + ActiveCount: 0x40b64n, + Epoch: 0x40b68n, + }); +}); diff --git a/js/net/src/lite/goaway.test.ts b/js/net/src/lite/goaway.test.ts index a051b010ce6..87e9ba6aee2 100644 --- a/js/net/src/lite/goaway.test.ts +++ b/js/net/src/lite/goaway.test.ts @@ -58,19 +58,9 @@ test("Goaway: round trip on draft-05", async () => { expect(decoded.uri).toBe("moql://relay.example/migrate"); }); -test("Goaway: rejects draft-01", async () => { +test.each(["DRAFT_01", "DRAFT_02", "DRAFT_03"] as const)("Goaway: rejects %s", async (version) => { const msg = new Goaway("https://example.com"); - await expect(encode(msg, Version.DRAFT_01)).rejects.toThrow(/not supported/); -}); - -test("Goaway: rejects draft-02", async () => { - const msg = new Goaway("https://example.com"); - await expect(encode(msg, Version.DRAFT_02)).rejects.toThrow(/not supported/); -}); - -test("Goaway: rejects draft-03", async () => { - const msg = new Goaway("https://example.com"); - await expect(encode(msg, Version.DRAFT_03)).rejects.toThrow(/not supported/); + await expect(encode(msg, Version[version])).rejects.toThrow(/not supported/); }); test("Goaway: decode rejects draft-01", async () => { diff --git a/js/net/src/path.test.ts b/js/net/src/path.test.ts index 297d9fb16dd..2f82253e527 100644 --- a/js/net/src/path.test.ts +++ b/js/net/src/path.test.ts @@ -111,18 +111,6 @@ test("join handles multiple joins", () => { expect(path).toBe("api/v1/users/123" as Path.Valid); }); -test("isEmpty checks correctly", () => { - expect(Path.from("") === "").toBe(true); - expect(Path.from("foo") === "").toBe(false); - expect(Path.empty() === "").toBe(true); -}); - -test("length property works correctly", () => { - expect(Path.from("foo").length).toBe(3); - expect(Path.from("foo/bar").length).toBe(7); - expect(Path.empty().length).toBe(0); -}); - test("equals checks correctly", () => { const path1 = Path.from("foo/bar"); const path2 = Path.from("/foo/bar/"); @@ -132,11 +120,6 @@ test("equals checks correctly", () => { expect(path1 === path3).toBe(false); }); -test("JSON serialization works", () => { - const path = Path.from("foo/bar"); - expect(JSON.stringify(path)).toBe('"foo/bar"'); -}); - test("handles paths with multiple consecutive slashes", () => { const path = Path.from("foo//bar///baz"); // Multiple consecutive slashes are collapsed to single slashes diff --git a/js/net/src/session-limits.test.ts b/js/net/src/session-limits.test.ts index 513f3a383c4..f6883d3fe8f 100644 --- a/js/net/src/session-limits.test.ts +++ b/js/net/src/session-limits.test.ts @@ -23,7 +23,7 @@ import { Timescale } from "./time.ts"; import type { Limits } from "./util/limits.ts"; import { wireOf } from "./wire.ts"; -// Small caps keep each case fast; util/limits.test.ts pins the real defaults. +// Small caps keep each case fast. const limits: Limits = { announces: 8, subscriptions: 4, fetches: 4 }; // A publisher serving one announced broadcast whose tracks are never accepted, so every diff --git a/js/net/src/track.test.ts b/js/net/src/track.test.ts index b031ed5c98a..0b004a9bdc7 100644 --- a/js/net/src/track.test.ts +++ b/js/net/src/track.test.ts @@ -34,13 +34,6 @@ function manualTime(initial: number) { }; } -test("priority reads the committed info and is the midpoint before accept", () => { - const producer = new TrackProducer("video"); - expect(producer.priority).toBe(127); - producer.accept({ priority: 60 }); - expect(producer.priority).toBe(60); -}); - test("wanted reflects subscriber demand and clears when the last one leaves", async () => { const producer = new TrackProducer("test"); @@ -2330,12 +2323,6 @@ test("finished rejects when the track aborts or closes without an end", async () expect(await reader.finished()).toEqual({ group: 1, frame: 0 }); }); -test("publisher max age is absent unless explicitly declared", () => { - expect(infoDefaults().maxAge).toBeUndefined(); - expect(infoDefaults({ maxAge: Milli.zero }).maxAge).toBe(Milli.zero); - expect(infoDefaults({ maxAge: Milli(30_000) }).maxAge).toBe(Milli(30_000)); -}); - // Rust applies the pool's idle expiry with `max_age: None` too: omitting the publisher // limit only removes the media-time clamp, never the wall-clock bound on memory. test("an omitted publisher limit still ages idle groups out", async () => { @@ -2550,11 +2537,6 @@ function untimedTrack(count: number): TrackProducer { return producer; } -test("a track is untimed unless it declares a timescale", () => { - expect(infoDefaults().timescale).toBeUndefined(); - expect(infoDefaults({ timescale: Timescale.MICRO }).timescale).toBe(Timescale.MICRO); -}); - test("a null timescale declares an untimed track, like an omitted one", () => { expect(infoDefaults({ timescale: null }).timescale).toBeUndefined(); diff --git a/js/net/src/util/limits.test.ts b/js/net/src/util/limits.test.ts index bde91d6b7ab..da1cdda264f 100644 --- a/js/net/src/util/limits.test.ts +++ b/js/net/src/util/limits.test.ts @@ -1,10 +1,6 @@ import { expect, mock, test } from "bun:test"; import { SessionCode } from "../error.ts"; -import { Interests, LIMITS, SlotMap, Slots } from "./limits.ts"; - -test("the session defaults match moq-net", () => { - expect(LIMITS).toEqual({ announces: 100_000, subscriptions: 10_000, fetches: 10_000 }); -}); +import { Interests, SlotMap, Slots } from "./limits.ts"; test("a full budget closes the session, and released slots can be used again", () => { const close = mock(() => {}); diff --git a/js/p2p/src/transport.test.ts b/js/p2p/src/transport.test.ts index 5dc2e96b831..d54c6f9b51b 100644 --- a/js/p2p/src/transport.test.ts +++ b/js/p2p/src/transport.test.ts @@ -50,8 +50,6 @@ test("qmux carries large streams in bounded binary records and preserves both st await Promise.all([client.ready, server.ready]); expect(left.options).toEqual({ ordered: true, protocol }); expect(left.channel.binaryType).toBe("arraybuffer"); - expect(client.protocol).toBe(protocol); - expect(server.protocol).toBe(protocol); expect(client.datagrams.maxDatagramSize).toBe(0); const payload = Uint8Array.from({ length: 256 * 1024 }, (_, i) => i % 251); const receiving = next(server.incomingUnidirectionalStreams).then(readAll); diff --git a/js/pattern/src/index.test.ts b/js/pattern/src/index.test.ts index d05b94ccada..a961c2fc59f 100644 --- a/js/pattern/src/index.test.ts +++ b/js/pattern/src/index.test.ts @@ -559,7 +559,7 @@ test("the pattern segment limit is immutable at runtime", () => { const original = Pattern.MAX_SEGMENTS; try { expect(Reflect.set(Pattern, "MAX_SEGMENTS", 33)).toBe(false); - expect(Pattern.MAX_SEGMENTS).toBe(32); + expect(Pattern.MAX_SEGMENTS).toBe(original); expect(errorCode(() => Pattern.parse(Array(33).fill("a").join("/")))).toBe("too-many-segments"); } finally { Reflect.set(Pattern, "MAX_SEGMENTS", original); diff --git a/js/publish/src/audio/encoder.test.ts b/js/publish/src/audio/encoder.test.ts index 0908da30211..683b0fc4e6d 100644 --- a/js/publish/src/audio/encoder.test.ts +++ b/js/publish/src/audio/encoder.test.ts @@ -22,11 +22,9 @@ describe("resolve", () => { expect(Audio.resolve).toBeUndefined(); }); - test("defaults Opus to 20ms", () => { - const resolved = resolve(captured, "opus"); - expect(resolved.frameDuration).toBe(Micro(20_000)); - expect(Number(resolved.catalog.warmup)).toBe(80); - expect(resolved.catalog.jitter).toBeUndefined(); + test("the default Opus catalog declares the RFC 7845 preroll", () => { + // 80ms per RFC 7845 section 4.6, matching WARMUP in rs/moq-mux/src/codec/opus/mod.rs. + expect(Number(resolve(captured, "opus").catalog.warmup)).toBe(80); }); // The exact frame duration does not imply encoder flush lateness. diff --git a/js/publish/src/source/device.test.ts b/js/publish/src/source/device.test.ts index 51b74e35bba..9485be2d3f5 100644 --- a/js/publish/src/source/device.test.ts +++ b/js/publish/src/source/device.test.ts @@ -132,8 +132,3 @@ test("a capture without a preference stays unpinned", async () => { mic.close(); }); - -test("installing media devices preserves browser identity", () => { - using _media = install(DESKTOP); - expect(typeof navigator.userAgent).toBe("string"); -}); diff --git a/js/publish/src/source/file.test.ts b/js/publish/src/source/file.test.ts index ec40cf1ce2f..26bf9e33dd8 100644 --- a/js/publish/src/source/file.test.ts +++ b/js/publish/src/source/file.test.ts @@ -19,8 +19,6 @@ test("the file picker opens before yielding to media loading", () => { try { source.prompt(); expect(click).toHaveBeenCalledTimes(1); - expect(input.type).toBe("file"); - expect(input.accept).toBe("image/*,video/*,audio/*"); } finally { source.close(); if (document) Object.defineProperty(globalThis, "document", document); diff --git a/js/room/src/metadata.test.ts b/js/room/src/metadata.test.ts index 68f6abd902a..20fcd9ee911 100644 --- a/js/room/src/metadata.test.ts +++ b/js/room/src/metadata.test.ts @@ -1,33 +1,26 @@ import { expect, test } from "bun:test"; -import { TRACK, userFields } from "./metadata.ts"; - -test("userFields seeds from values", () => { - const user = userFields({ id: "a", name: "Ada", avatar: "ada.png" }); - expect(user.id.peek()).toBe("a"); - expect(user.name.peek()).toBe("Ada"); - expect(user.avatar.peek()).toBe("ada.png"); - expect(user.color.peek()).toBeUndefined(); -}); - -test("core tracks are hang/*.json and extras share the section", () => { - expect(TRACK.user).toBe("hang/user.json"); - expect(TRACK.preview).toBe("hang/preview.json"); - expect(TRACK.chat).toBe("hang/chat.json"); - expect(TRACK.location).toBe("hang/location.json"); -}); - import * as Json from "@moq/json"; import * as Net from "@moq/net"; import type * as Publish from "@moq/publish"; import { Effect, Signal } from "@moq/signals"; import type * as Watch from "@moq/watch"; -import { consume, type ExtendedCatalog, type Preview, serve } from "./metadata.ts"; +import { consume, type ExtendedCatalog, type Preview, serve, TRACK, userFields } from "./metadata.ts"; // Drain queued effects and their asynchronous subscription continuations. async function flush() { for (let i = 0; i < 30; i++) await Promise.resolve(); } +// Track names are wire identifiers shared with every other publisher and subscriber. +test("track names match the hang catalog section", () => { + expect({ ...TRACK }).toEqual({ + user: "hang/user.json", + preview: "hang/preview.json", + chat: "hang/chat.json", + location: "hang/location.json", + }); +}); + test("metadata updates keep the same track and reach an existing subscriber", async () => { const net = new Net.Broadcast.Producer(); const catalog = new Signal({}); diff --git a/js/watch/src/audio/ring-buffer.test.ts b/js/watch/src/audio/ring-buffer.test.ts index 1956fa568f9..df5aa42e7ce 100644 --- a/js/watch/src/audio/ring-buffer.test.ts +++ b/js/watch/src/audio/ring-buffer.test.ts @@ -169,12 +169,6 @@ describe("writing data", () => { // Available should still be 80 (unchanged because old samples were discarded) expect(buffer.length).toBe(80); }); - - it("should not throw when writing to buffer", () => { - const buffer = new AudioRingBuffer({ rate: 1000, channels: 2, latency: 100 as Milli }); - // The current implementation doesn't require initialization - expect(() => write(buffer, 0 as Milli, 10, { channels: 2, value: 0.0 })).not.toThrow(); - }); }); describe("reading data", () => { @@ -243,12 +237,6 @@ describe("reading data", () => { const output = read(buffer, 10, 2); expect(output[0].length).toBe(0); }); - - it("should return 0 when not initialized", () => { - const buffer = new AudioRingBuffer({ rate: 1000, channels: 2, latency: 100 as Milli }); - const output = read(buffer, 10, 2); - expect(output[0].length).toBe(0); - }); }); describe("stall behavior", () => { @@ -659,12 +647,6 @@ describe("decoded rate must match the ring (#2352)", () => { // 20ms at 48kHz is exactly 960 samples, so 10 frames pack into 9600 with no gaps or overlap. expect(writeOpusFrames(48000).length).toBe(9600); }); - - it("misplaces the frames when the ring rate disagrees", () => { - // 20ms at 44100 is 882 samples, so each 960-sample frame overlaps the next and the buffer never - // reaches the contiguous 9600 it would at the matching rate. - expect(writeOpusFrames(44100).length).toBeLessThan(9600); - }); }); describe("live anchoring", () => { diff --git a/js/watch/src/audio/shared-ring-buffer.test.ts b/js/watch/src/audio/shared-ring-buffer.test.ts index 35a62951fa9..e4d03ed01c4 100644 --- a/js/watch/src/audio/shared-ring-buffer.test.ts +++ b/js/watch/src/audio/shared-ring-buffer.test.ts @@ -64,16 +64,6 @@ function read(buffer: SharedRingBuffer, samples: number, channelCount?: number): } describe("initialization", () => { - it("should allocate correct SAB sizes", () => { - const init = allocSharedRingBuffer(2, 128, 1000); - expect(init.channels).toBe(2); - expect(init.capacity).toBe(128); - expect(init.rate).toBe(1000); - expect(init.samples.byteLength).toBe(2 * 128 * 4); // 2 channels * 128 samples * Float32 - expect(init.control.byteLength).toBe(6 * 4); // 6 control slots * Int32 - expect(init.state.byteLength).toBe(8); // packed epoch + read cursor - }); - it("rounds capacity up to a power of two", () => { // slot() masks rather than taking a remainder, which is what keeps it wrap-invariant. expect(allocSharedRingBuffer(1, 100, 1000).capacity).toBe(128); @@ -82,12 +72,6 @@ describe("initialization", () => { expect(allocSharedRingBuffer(1, 1, 1000).capacity).toBe(1); }); - it("should start stalled", () => { - const buffer = create(); - expect(buffer.stalled).toBe(true); - expect(buffer.length).toBe(0); - }); - it("should throw on invalid channels", () => { expect(() => allocSharedRingBuffer(0, 100, 1000)).toThrow(/invalid channels/); }); diff --git a/py/moq-ffi/tests/test_smoke.py b/py/moq-ffi/tests/test_smoke.py deleted file mode 100644 index 1eb210a8f10..00000000000 --- a/py/moq-ffi/tests/test_smoke.py +++ /dev/null @@ -1,15 +0,0 @@ -"""Smoke test: the raw uniffi bindings import and expose the core classes.""" - -import moq_ffi - - -def test_exports_core_classes(): - # A representative slice of the generated surface. If uniffi-bindgen output - # or module-name wiring breaks, these attributes disappear. - for name in ("MoqClient", "MoqServer", "MoqBroadcastProducer", "MoqError"): - assert hasattr(moq_ffi, name), f"moq_ffi missing {name}" - - -def test_client_constructs(): - client = moq_ffi.MoqClient(moq_ffi.MoqClientConfig()) - assert client is not None diff --git a/py/moq-rs/tests/test_local.py b/py/moq-rs/tests/test_local.py index 6b754cc3700..7bd5fcbc970 100644 --- a/py/moq-rs/tests/test_local.py +++ b/py/moq-rs/tests/test_local.py @@ -101,11 +101,6 @@ def h264_init() -> bytes: return sps + pps -def test_origin_lifecycle(): - origin = moq.OriginProducer() - _consumer = origin.consume() - - async def test_fetch_abort_is_a_stream_app_code(): broadcast = moq.BroadcastProducer() track = broadcast.publish_track("events") @@ -153,7 +148,6 @@ def test_protocol_error_helper_covers_known_app_and_unknown(): def test_error_str_is_rust_display(): assert str(moq.Error.Closed()) == "closed" # type: ignore[attr-defined] error = moq.Error.Transport(reason="reset") # type: ignore[attr-defined] - assert error.reason == "reset" assert str(error) == "transport: reset" details = moq.ProtocolError(scope=moq.ErrorScope.STREAM, code=468, kind=moq.ProtocolKind.APP, message="gone") assert str(moq.Error.Protocol(details)) == "gone" # type: ignore[attr-defined] @@ -1295,28 +1289,6 @@ async def test_read_frame_keeps_group_across_cancelled_call(): assert await asyncio.wait_for(consumer.read_frame(), timeout=5.0) is None -def test_optional_binding_records_use_none_defaults(): - """Optional UniFFI record fields are optional in generated constructors.""" - hint = moq.media.VideoHint() - assert hint.coded is None - assert hint.display_aspect is None - assert hint.bitrate is None - assert hint.framerate is None - assert hint.optimize_for_latency is None - - encoder = moq.audio.EncoderOutput(codec=moq.AudioCodec.opus()) - assert encoder.sample_rate is None - assert encoder.channels is None - assert encoder.bitrate is None - assert encoder.frame_duration == timedelta(0) - - decoder = moq.audio.DecoderOutput(format=moq.AudioSampleFormat.F32) - assert decoder.sample_rate is None - assert decoder.channels is None - assert decoder.max_delay is None - assert decoder.delay is None - - def test_audio_encoder_returns_namespaced_records(): """The codec-only encoder's results are named under ``moq.audio``.""" encoder = moq.audio.Encoder(moq.audio.EncoderOutput(codec=moq.AudioCodec.opus(), sample_rate=48000, channels=1)) diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index 0b998d85d4a..f59b19d54dc 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -195,13 +195,6 @@ def test_ci_runs_one_lint_preamble_and_one_test_pass(self): self.assertLess(next(i for i, call in enumerate(calls) if call.startswith("rs lint-changed ")), next(i for i, call in enumerate(calls) if call.startswith("rs test-changed "))) - def test_removed_halves_fail_before_running_anything(self): - for action in ("ci-check", "ci-test"): - result = subprocess.run(["bash", "sh/dispatch.sh", action, "origin/main"], - cwd=self.repo, env=self.env, text=True, capture_output=True) - self.assertEqual(result.returncode, 2) - self.assertEqual(result.stdout, "") - def benchmark(): # Sweep path count and both job selections. No timing threshold: hosted setup diff --git a/sh/gh/cpp.test.ts b/sh/gh/cpp.test.ts index 913de1f4e67..8a154f12d92 100644 --- a/sh/gh/cpp.test.ts +++ b/sh/gh/cpp.test.ts @@ -1,21 +1,10 @@ -// biome-ignore-all lint/suspicious/noTemplateCurlyInString: GitHub Actions expressions are literal strings. import { expect, test } from "bun:test"; import { YAML } from "bun"; -test("C++ dry runs check packaged archives and build OBS without publishing", async () => { +test("OBS builds on branch dry runs, and on tags only after the C++ release succeeds", async () => { const workflow = YAML.parse(await Bun.file(".github/workflows/release-cpp.yml").text()); - const jobs = workflow.jobs; - expect(jobs.build.steps.find((step: { name: string }) => step.name === "Check packaged archive")?.run).toContain( - "just cpp check --archive", - ); - expect(jobs["obs-build"].needs).toEqual(["build", "release"]); - const runs = new Function( - "github", - "needs", - "always", - "cancelled", - `return (${jobs["obs-build"].if.replace(/\$\{\{|\}\}/g, "")});`, - ); + const job = workflow.jobs["obs-build"]; + const runs = new Function("github", "needs", "always", "cancelled", `return (${job.if.replace(/\$\{\{|\}\}/g, "")});`); for (const [ref, build, release, wanted] of [ ["branch", "success", "skipped", true], ["tag", "success", "success", true], @@ -26,13 +15,4 @@ test("C++ dry runs check packaged archives and build OBS without publishing", as wanted, ); } - const steps = jobs["obs-build"].steps; - expect(steps.find((step: { name: string }) => step.name === "Download local C++ archive").if).toBe( - "github.ref_type != 'tag'", - ); - expect(steps.find((step: { name: string }) => step.name === "Download local C++ archive").with.name).toBe( - "moq-cpp-${{ matrix.target }}", - ); - expect(steps.find((step: { name: string }) => step.name === "Build and package").run).toContain("--moq-archive"); - for (const name of ["release", "obs-release"]) expect(jobs[name].if).toBe("github.ref_type == 'tag'"); }); diff --git a/sh/gh/ffi.test.ts b/sh/gh/ffi.test.ts index 9cc3292f89e..366c03cac0a 100644 --- a/sh/gh/ffi.test.ts +++ b/sh/gh/ffi.test.ts @@ -9,7 +9,6 @@ type Job = { needs?: string[]; permissions?: Record; with?: Record; - strategy?: { "fail-fast": boolean }; steps?: { name?: string; if?: string; env?: Record; with?: Record; run?: string }[]; }; type Workflow = { @@ -24,7 +23,6 @@ async function read(name: string): Promise { test("shared default builds cover each consumer exactly once", async () => { const shared = await read("release-shared-ffi"); const targets = JSON.parse(shared.jobs.native.with?.targets as string) as string[]; - expect(targets.length).toBe(9); expect(new Set(targets).size).toBe(targets.length); const all: string[] = []; for (const [job, file] of [ @@ -44,28 +42,11 @@ test("shared default builds cover each consumer exactly once", async () => { expect(select?.env?.LIB_PREFIX).toContain("'default'"); } expect([...new Set(all)].sort()).toEqual(targets.toSorted()); - expect(all.length - targets.length).toBe(5); expect(shared.on.push?.tags).toEqual(["moq-ffi-v*"]); const dart = await read("release-dart-ffi"); expect(dart.on.push?.tags).toEqual(["moq-ffi-v*"]); }); -test("bindings reuse Linux metadata even when an unrelated target fails", async () => { - const producer = await read("release-ffi"); - expect(producer.jobs.build.strategy?.["fail-fast"]).toBe(false); - expect(producer.jobs.bindings.strategy?.["fail-fast"]).toBe(false); - expect(producer.jobs.bindings.needs).toContain("build"); - expect(producer.jobs.bindings.if).toContain("always()"); - expect(producer.jobs.bindings.if).toContain("!inputs.reuse-native"); - expect(producer.jobs.build.if).toContain("!inputs.reuse-native"); - const steps = producer.jobs.bindings.steps ?? []; - expect(steps.find((s) => s.name === "Download binding metadata")?.with?.name).toBe( - "${{ inputs.language }}-lib-x86_64-unknown-linux-gnu", - ); - expect(steps.find((s) => s.name === "Generate bindings")?.run).toContain("--library binding-library/libmoq_ffi.so"); - expect(steps.find((s) => s.name === "Upload bindings")?.with?.name).toBe("${{ matrix.language }}-bindings"); -}); - test("wrapper gates preserve trusted tag inputs and inspect only their publisher", async () => { for (const [file, language, first] of [ ["go", "go", "build"], @@ -94,8 +75,6 @@ test("wrapper gates preserve trusted tag inputs and inspect only their publisher test("Nightly and alert chains retain packaged outputs with one shared producer", async () => { const nightly = await read("nightly"); expect(nightly.jobs["release-shared-ffi"].uses).toBe("./.github/workflows/release-shared-ffi.yml"); - for (const old of ["release-go-ffi", "release-kt-ffi", "release-swift-ffi"]) - expect(nightly.jobs[old]).toBeUndefined(); expect(nightly.jobs.sizes.needs).toContain("release-shared-ffi"); expect(nightly.jobs["release-py-ffi"]).toBeDefined(); expect(nightly.jobs["release-dart-ffi"]).toBeDefined(); diff --git a/sh/gh/queue.test.ts b/sh/gh/queue.test.ts index 9ba06b8eb38..1dea03014dd 100644 --- a/sh/gh/queue.test.ts +++ b/sh/gh/queue.test.ts @@ -167,11 +167,7 @@ for (const job of ["release-swift-lib", "release-dart-ffi", "release-dart", "rel assert.ok(nightly.jobs[job], `nightly must dry-run ${job}`); } -assert.equal((await workflow("obs")).jobs.release, undefined); assert.deepEqual((await workflow("obs")).on.push.branches, ["release"]); -assert.equal((await workflow("cpp")).jobs.msvc, undefined); -assert.deepEqual((await workflow("moq-sh")).jobs.test.strategy.matrix.os, ["ubuntu-latest"]); -assert.equal(await Bun.file(".github/workflows/swift.yml").exists(), false); // Release Dart FFI only runs on release PRs and nightly, so it packages every platform. const targets = JSON.parse(dart.jobs.ffi.with.targets); diff --git a/sh/gh/setup.test.ts b/sh/gh/setup.test.ts index 71637173c11..90baf6a781a 100644 --- a/sh/gh/setup.test.ts +++ b/sh/gh/setup.test.ts @@ -7,7 +7,6 @@ type Step = { uses?: string; run?: string; if?: string; - env?: Record; "continue-on-error"?: boolean; }; type Job = { name: string; if?: string; steps: Step[]; "runs-on": string }; @@ -23,11 +22,6 @@ for (const name of ["check"]) { const scopeIndex = job.steps.findIndex((step) => step.id === "scope"); expect(scopeIndex).toBeGreaterThan(0); const scope = job.steps[scopeIndex]; - expect(scope.run).toBe('just ci-select "$CI_BASE" >> "$GITHUB_OUTPUT"'); - expect(scope.env?.CI_BASE).toBe( - // biome-ignore lint/suspicious/noTemplateCurlyInString: GitHub expression is literal YAML. - "${{ github.base_ref == 'release' && '--all' || github.event.merge_group.base_sha }}", - ); expect(scope.if).toBeUndefined(); expect(scope["continue-on-error"]).toBeUndefined(); expect(job.steps.slice(0, scopeIndex).some((step) => step.uses === "./.github/actions/just")).toBe(true); @@ -54,24 +48,6 @@ for (const name of ["check"]) { }); } -test("scope queries support both merge groups and release PRs without path filters", () => { - expect(workflow.on.merge_group).toEqual({ types: ["checks_requested", "destroyed"] }); - expect(workflow.on.pull_request).toBeDefined(); - expect(workflow.on.pull_request).not.toHaveProperty("paths"); - expect(workflow.on.pull_request).not.toHaveProperty("branches"); -}); - -// Main PRs must still report the required name, as skipped, and a PR -// retargeted to release must run it, so `edited` triggers a fresh run. -test("main PRs skip Check while the queue and release PRs run it", () => { - expect(workflow.on.pull_request).toEqual({ types: ["opened", "synchronize", "reopened", "edited", "closed"] }); - for (const name of ["check"]) { - expect(workflow.jobs[name].if).toBe( - "github.event.action != 'closed' && github.event.action != 'destroyed' && (github.event_name != 'pull_request' || github.base_ref == 'release')", - ); - } -}); - test("self-hosted queue jobs use local caches without R2 credentials", async () => { const action = Bun.YAML.parse(await Bun.file(".github/actions/rust-cache/action.yml").text()); const setup = action.runs.steps.find((step: Step) => step.uses?.startsWith("jdx/mr-boxington-action@")); @@ -109,5 +85,4 @@ test("one job runs one CI dispatch with one checkout and cache restore", () => { expect(steps.filter((step) => step.uses === "./.github/actions/nix")).toHaveLength(1); expect(steps.filter((step) => step.uses === "./.github/actions/rust-cache")).toHaveLength(1); expect(steps.filter((step) => step.run?.includes("nix develop"))).toHaveLength(1); - expect(steps.at(-1)?.run).toBe('nix develop --command just ci "$CI_BASE"'); });