Files
usenet-indexer/tests/unit/edge/wire.spec.ts
T
Daan MeijerandClaude Opus 5.5 fc1c64d5c0
Test and deploy / test (push) Successful in 24s
Test and deploy / deploy (push) Successful in 1m0s
Rebuild: drop NUL from batches; chunk deadline 180 s
A file name with a NUL ("…Brutal Erpresst.ra\u0000…") failed every
batch of range 155595 (HTTP 500, jsonb: \u0000 cannot be converted to
text), so the range looped. fromWire drops NUL from every string.

The chunk deadline was given up 258 times in 3 hours at 300 s (~1.4 a
minute, each holding a connection for 5 minutes): 180 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 13:12:27 +02:00

23 lines
825 B
TypeScript

import { test } from '@japa/runner'
import { fromWire, type WireBatch } from '#lib/edge/index'
test.group('edge / wire', () => {
test('fromWire drops NUL from strings, wherever they are', ({ assert }) => {
const wire = {
from: 1,
next: 2,
headers: 1,
releases: [{ key: 'k', name: 'Brutal.ra\u0000r', payload: Buffer.from('x').toString('base64') }],
samples: [],
candidates: [],
counts: [],
fragments: [{ fileKey: 'f', segments: [['a\u0000b.rar', 1, 2, 3]] }],
} as unknown as WireBatch
const batch = fromWire(wire) as any
assert.equal(batch.releases[0].name, 'Brutal.rar')
assert.equal(batch.releases[0].payload.toString(), 'x')
assert.equal(batch.fragments[0].segments[0][0], 'ab.rar')
assert.equal(batch.fragments[0].segments[0][3], 3)
})
})