From d72fe2f13fc029af62f3dd1094663ec100363019 Mon Sep 17 00:00:00 2001 From: Daan Meijer Date: Sun, 11 Oct 2026 14:22:10 +0200 Subject: [PATCH] Tests: a corrupt chunk fails its range on the third report Co-Authored-By: Claude Opus 5.5 --- tests/functional/node_api.spec.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/functional/node_api.spec.ts b/tests/functional/node_api.spec.ts index eafa7b7..e811892 100644 --- a/tests/functional/node_api.spec.ts +++ b/tests/functional/node_api.spec.ts @@ -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') }) })