import { expect, test } from "../fixtures/resilienceHarness"; const fastResilienceConfig = { connectTimeoutMs: 250, healthCheckIntervalMs: 50, reconnectBaseDelayMs: 50, reconnectMaxDelayMs: 100, reconnectDelayGrowFactor: 1.2, minConnectionUptimeMs: 0, maxReconnectAttempts: 4, }; test.describe("Degraded network server faults", () => { test("R016 delays, drops, and stalls outbound delivery", async ({ harness, scriptedServer, }) => { await harness.start({ resilience: fastResilienceConfig, speechPlan: [ { kind: "speech", durationMs: 900 }, { kind: "silence", durationMs: 120 }, { kind: "speech", durationMs: 900 }, { kind: "silence", durationMs: 120 }, { kind: "speech", durationMs: 900 }, ], }); await scriptedServer.waitForConnectionCount(1); scriptedServer.clearTransportLog(); scriptedServer.clearFaults(); scriptedServer.delayFrames(75); scriptedServer.dropEveryNthFrame(3); scriptedServer.sendFinal("degraded final one"); scriptedServer.sendFinal("degraded final two"); scriptedServer.sendFinal("degraded final three"); scriptedServer.stallDrain(150); scriptedServer.sendFinal("degraded final four"); await harness.waitForFinalCount(3); await harness.stop(); await scriptedServer.waitForFinish(); const transcript = await harness.getTranscript(); const transportLog = scriptedServer.getTransportLog(); expect(transcript).toContain("degraded final one"); expect(transcript).toContain("degraded final two"); expect(transcript).toContain("degraded final four"); expect(transcript).not.toContain("degraded final three"); expect( transportLog.some((entry) => entry.type === "outbound-frame-delayed") ).toBeTruthy(); expect( transportLog.some((entry) => entry.type === "outbound-frame-dropped") ).toBeTruthy(); expect( transportLog.some((entry) => entry.type === "drain-stalled") ).toBeTruthy(); expect(transportLog.some((entry) => entry.type === "finish")).toBeTruthy(); }); });