Skip to content

The agent that grows with you

test(cron): settled receipt test waits for the receipt cron reads, not the admission row

Teknium05c26d0bff03
diff --git a/tests/gateway/test_cron_canonical_receipt_regression.py b/tests/gateway/test_cron_canonical_receipt_regression.py
index c673eeabbe7..0717a7fb730 100644
--- a/tests/gateway/test_cron_canonical_receipt_regression.py
+++ b/tests/gateway/test_cron_canonical_receipt_regression.py
@@ -105,8 +105,13 @@ def test_cron_tracks_real_canonical_receipt(canonical_bot, phase):
assert len(before) == 1 and before[0]['status'] == 'queued', (initial, before)
admission_id = before[0]['admission_id']
if phase == 'settled':
+ from tools.bot_live_delivery import read_delivery_result
+ key = job['_bot_chat_delivery_receipts']['bot-chat:(own)']['delivery_id']
bot.model.release.set()
wait_for(lambda: owned_rows()[0]['status'] == 'terminal')
+ # The owner republishes the receipt cron reads from an async refresh AFTER the row commits;
+ # until then cron correctly reports "claimed ... do not resend". Sync on the published receipt.
+ wait_for(lambda: (read_delivery_result(bot.home, key) or {}).get('status') == 'settled')
observed = _deliver_to_bot_chat(job, content, '')
else:
observed = initial