fix: wait out processing until the certificate exists

A global stamp now polls status processing the same way as pending
and returns only the completed result. The debug trace for
Verae-Debug-Test records one receipt id.
This commit is contained in:
George Lambert 2026-09-23 11:37:13 -04:00
commit b89c4ad4d2

View file

@ -97,6 +97,38 @@ async def test_existing_digest_returns_first_certificate_without_status_poll():
assert len(http.calls) == 1
async def test_processing_status_polls_until_certificate():
class ProcessingHttp(FakeHttp):
def __init__(self):
super().__init__()
self.status_calls = 0
def request(self, method, url, payload, headers):
self.calls.append((method, url, payload, headers))
if url.endswith("/api/timestamp"):
return _Resp(202, {"jobId": "job-p"})
if url.endswith("/api/status/job-p"):
self.status_calls += 1
if self.status_calls < 3:
return _Resp(200, {"id": "job-p", "status": "processing"})
return _Resp(
200,
{
"id": "job-p",
"status": "completed",
"result": "QmDone",
"metadata": {"timestamp": "2026-09-23T00:00:00Z", "blockHash": "0xabc"},
},
)
return _Resp(404, {"error": "nope"})
http = ProcessingHttp()
rec = GlobalClient("https://api.veraetime.net", http=http).submit(SHA256_EMPTY)
assert rec.receipt_id == "QmDone"
assert rec.receipt_id != "job-p"
assert http.status_calls == 3
async def test_existing_without_certificate_polls_job():
class PendingExisting(FakeHttp):
def request(self, method, url, payload, headers):