fix: post data+SHA256 to VeraeTime and poll job for CID certificate

Live /api/timestamp rejects {hash,sync}; it wants {data,hashAlg:SHA256}
and returns a job whose result is a multihash certificate.
This commit is contained in:
George Lambert 2026-09-20 10:18:24 -04:00
commit b1219c64bc

View file

@ -29,7 +29,7 @@ class FakeHttp:
200,
{
"jobId": "job-1",
"hash": payload["hash"],
"hash": payload.get("data") or payload.get("hash"),
"timestamp": "2026-08-15T00:00:00Z",
"blockHash": "0xdead",
},
@ -38,6 +38,16 @@ class FakeHttp:
if payload.get("certificate") == "job-1":
return _Resp(200, {"valid": True, "hash": SHA256_EMPTY})
return _Resp(200, {"valid": False})
if "/api/status/" in url:
return _Resp(
200,
{
"id": "job-1",
"status": "completed",
"result": "job-1",
"metadata": {"timestamp": "2026-08-15T00:00:00Z", "blockHash": "0xdead"},
},
)
return _Resp(404, {"error": "nope"})
@ -49,7 +59,7 @@ async def test_global_stamp_posts_hash_sync_and_maps_receipt():
method, url, payload, headers = http.calls[0]
assert method == "POST"
assert url == "https://api.veraetime.net/api/timestamp"
assert payload == {"hash": SHA256_EMPTY, "sync": True}
assert payload == {"data": SHA256_EMPTY, "hashAlg": "SHA256"}
assert headers["Authorization"] == "Bearer secret"
assert rec.scope == "global"
assert rec.receipt_id == "job-1"
@ -84,7 +94,7 @@ async def test_routing_sends_only_global_scope_to_central():
[g] = await routed.stamp(SHA256_EMPTY, scope="global", cube_id="cube-1")
assert g.scope == "global"
assert g.receipt_id == "job-1"
assert len(http.calls) == 1
assert http.calls[0][1].endswith("/api/timestamp")
cached = await routed.hash_report(SHA256_EMPTY, want_scope="global")
assert cached[0].receipt_id == "job-1"