diff --git a/billing/lib/ucan-stream.js b/billing/lib/ucan-stream.js index 1618e19e..58871a41 100644 --- a/billing/lib/ucan-stream.js +++ b/billing/lib/ucan-stream.js @@ -99,6 +99,11 @@ export const storeSpaceUsageDeltas = async (deltas, ctx) => { spaceDiffs.push(...res.ok) } + if (spaceDiffs.length === 0) return { + ok: 'no space diffs to store', + error: undefined + } + return ctx.spaceDiffStore.batchPut(spaceDiffs) } diff --git a/billing/test/lib/ucan-stream.js b/billing/test/lib/ucan-stream.js index 65d9b242..80786f13 100644 --- a/billing/test/lib/ucan-stream.js +++ b/billing/test/lib/ucan-stream.js @@ -229,7 +229,7 @@ export const test = { const deltas = findSpaceUsageDeltas(receipts) const storeDeltasRes = await storeSpaceUsageDeltas(deltas, ctx) - assert.equal(storeDeltasRes.error?.name, 'InsufficientRecords') + assert.equal(storeDeltasRes.ok, 'no space diffs to store') const res = await ctx.spaceDiffStore.list({ provider: consumer.provider,