diff --git a/packages/web/server/lib/relay/flow-control.test.js b/packages/web/server/lib/relay/flow-control.test.js index 4601b5f2..d93847fb 100644 --- a/packages/web/server/lib/relay/flow-control.test.js +++ b/packages/web/server/lib/relay/flow-control.test.js @@ -46,8 +46,6 @@ async function exercise({ clientFlow = true, hostFlow = true, batch = true, canc let hostData; const waiting = []; const down = []; - let pendingBytes = 0; - let peakBytes = 0; // This fixture brokers an isolated room only; it does not replace production // relay authentication. Neither WebSocket leg fails or drops a frame. relay.on('connection', (socket, req) => { @@ -67,8 +65,6 @@ async function exercise({ clientFlow = true, hostFlow = true, batch = true, canc for (const frame of waiting.splice(0)) socket.send(frame.data, { binary: frame.binary }); socket.on('message', (data, binary) => { down.push({ data, binary }); - pendingBytes += data.length; - peakBytes = Math.max(peakBytes, pendingBytes); }); } }); @@ -80,7 +76,6 @@ async function exercise({ clientFlow = true, hostFlow = true, batch = true, canc while (down.length && down[0].data.length <= credit) { const frame = down.shift(); credit -= frame.data.length; - pendingBytes -= frame.data.length; clientSocket.send(frame.data, { binary: frame.binary }); } }, 5); @@ -141,7 +136,7 @@ async function exercise({ clientFlow = true, hostFlow = true, batch = true, canc if (!cancel) expect(Buffer.concat(chunks).equals(content)).toBe(true); if (websocket) expect(wsMessages).toBe(2); expect(states).toEqual(['connected']); - return { bytesAtProbe, peakBytes, total }; + return { bytesAtProbe, total }; } finally { client.close(); host.stop(); @@ -159,7 +154,8 @@ describe('end-to-end downstream credit', () => { test('small HTTP response overtakes bulk output without losing bytes or reconnecting', async () => { const result = await exercise(); expect(result.bytesAtProbe).toBeLessThan(result.total / 2); - expect(result.peakBytes).toBeLessThan(192 * 1024); + // Queue peaks depend on real ACK timing and include encryption overhead. + // downstream-scheduler.test.js checks credit bounds with a controlled clock. }); test('works without batching', async () => { const result = await exercise({ batch: false });