web: economy reads real ledger field names (from_id/to_id); fixtures match live shape

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
m2 (AI Agent) 2026-07-02 05:54:53 +02:00
parent 63b39ed39b
commit 543d07b6a1
2 changed files with 7 additions and 7 deletions

View file

@ -21,8 +21,8 @@ def _headers() -> dict[str, str]:
def _tx_dto(tx: dict[str, Any]) -> dict[str, Any]: def _tx_dto(tx: dict[str, Any]) -> dict[str, Any]:
return { return {
"ts": tx.get("ts"), "ts": tx.get("ts"),
"from": tx.get("from"), "from": tx.get("from_id", tx.get("from")),
"to": tx.get("to"), "to": tx.get("to_id", tx.get("to")),
"amount": tx.get("amount"), "amount": tx.get("amount"),
"reason": tx.get("reason"), "reason": tx.get("reason"),
"ref": tx.get("ref"), "ref": tx.get("ref"),
@ -91,7 +91,7 @@ async def economy() -> dict[str, Any] | JSONResponse:
{ {
party party
for tx in transactions for tx in transactions
for party in (tx.get("from"), tx.get("to")) for party in (tx.get("from_id", tx.get("from")), tx.get("to_id", tx.get("to")))
if party and party != "mint" if party and party != "mint"
} }
) )

View file

@ -101,7 +101,7 @@ def _ok_transport(request: httpx.Request) -> httpx.Response:
"transactions": [ "transactions": [
{ {
"ts": "2026-07-02T09:00:00Z", "ts": "2026-07-02T09:00:00Z",
"from": "mint", "from_id": "mint",
"to": "m2bd", "to": "m2bd",
"amount": 50, "amount": 50,
"reason": "grant", "reason": "grant",
@ -116,8 +116,8 @@ def _ok_transport(request: httpx.Request) -> httpx.Response:
200, 200,
json={ json={
"transactions": [ "transactions": [
{"from": "mint", "to": "m2bd", "amount": 50}, {"from_id": "mint", "to_id": "m2bd", "amount": 50},
{"from": "m2bd", "to": "platform", "amount": 8}, {"from_id": "m2bd", "to_id": "platform", "amount": 8},
] ]
}, },
) )
@ -187,7 +187,7 @@ def test_catalog_wallet_economy_governance_happy_paths(
assert wallet.json()["balance"] == 42 assert wallet.json()["balance"] == 42
assert wallet.json()["transactions"][0] == { assert wallet.json()["transactions"][0] == {
"ts": "2026-07-02T09:00:00Z", "ts": "2026-07-02T09:00:00Z",
"from": "mint", "from_id": "mint",
"to": "m2bd", "to": "m2bd",
"amount": 50, "amount": 50,
"reason": "grant", "reason": "grant",