Tests: a corrupt chunk fails its range on the third report
Test and deploy / test (push) Successful in 22s
Test and deploy / deploy (push) Successful in 1m31s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-11 14:22:10 +02:00
1 parent fa52d9256b
commit d72fe2f13f
1 file changed
+9 -6
+9 -6
View File
@@ -105,12 +105,15 @@ test.group('Node API', (group) => {
assert.deepEqual(range.plain_chunks.map(Number), [101])
// No longer this node's: a second report is refused.
;(await client.post(`/api/v1/node/ranges/${rangeId}/corrupt`).bearerToken(token).json({ from: 101 })).assertStatus(409)
// Leased again and the plain chunk still doesn't inflate: the range is set aside, not leased in a loop.
await Spool.write(rangeId, { from: 101, to: 200 }, chunk(111))
;(await client.post('/api/v1/node/lease').bearerToken(token)).assertStatus(200)
;(await client.post(`/api/v1/node/ranges/${rangeId}/corrupt`).bearerToken(token).json({ from: 101 })).assertStatus(200)
range = await db.from('ranges').where('id', rangeId).first()
assert.equal(range.status, 'failed')
// Leased again, the chunk still doesn't inflate: once more (the compressed copy may have been spooled
// again meanwhile), then the range is set aside, not leased in a loop.
for (const status of ['planned', 'failed']) {
await Spool.write(rangeId, { from: 101, to: 200 }, chunk(111))
;(await client.post('/api/v1/node/lease').bearerToken(token)).assertStatus(200)
;(await client.post(`/api/v1/node/ranges/${rangeId}/corrupt`).bearerToken(token).json({ from: 101 })).assertStatus(200)
range = await db.from('ranges').where('id', rangeId).first()
assert.equal(range.status, status)
}
assert.include(range.error, 'also fetched plain')
})
})