()
| 74 | |
| 75 | // Ringbuffer grow — push > 16 items without consumer draining |
| 76 | async function testRingbufferGrow() { |
| 77 | const { writer, broadcast: bc } = broadcast({ highWaterMark: 32 }); |
| 78 | const consumer = bc.push(); |
| 79 | |
| 80 | // Push 20 items (exceeds default ringbuffer capacity of 16) |
| 81 | for (let i = 0; i < 20; i++) { |
| 82 | writer.writeSync(new Uint8Array([i])); |
| 83 | } |
| 84 | writer.endSync(); |
| 85 | |
| 86 | // Read all items back and verify order |
| 87 | const items = []; |
| 88 | for await (const batch of consumer) { |
| 89 | for (const chunk of batch) { |
| 90 | items.push(chunk[0]); |
| 91 | } |
| 92 | } |
| 93 | assert.strictEqual(items.length, 20); |
| 94 | for (let i = 0; i < 20; i++) { |
| 95 | assert.strictEqual(items[i], i); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // Multiple consumers at the minimum cursor should trim only after the last |
| 100 | // one advances or detaches. |
no test coverage detected
searching dependent graphs…