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') }) })