diff --git a/src/aleph/chains/chain_data_service.py b/src/aleph/chains/chain_data_service.py index 219a01d8..2e83c2b1 100644 --- a/src/aleph/chains/chain_data_service.py +++ b/src/aleph/chains/chain_data_service.py @@ -1,4 +1,5 @@ import asyncio +import json from typing import Any, Dict, List, Mapping, Optional, Self, Set, Type, Union, cast import aio_pika.abc @@ -191,7 +192,7 @@ def _get_tx_messages_smart_contract_protocol(tx: ChainTxDb) -> List[Dict[str, An item_hash=ItemHash(payload.content), metadata=None, ) - item_content = content.model_dump_json(exclude_none=True) + item_content = json.dumps(content.model_dump(exclude_none=True)) else: item_content = payload.content diff --git a/tests/api/test_balance.py b/tests/api/test_balance.py index c37d1b44..2064ed8a 100644 --- a/tests/api/test_balance.py +++ b/tests/api/test_balance.py @@ -23,5 +23,5 @@ async def test_get_balance( response = await ccn_api_client.get(MESSAGES_URI) assert response.status == 200, await response.text() data = await response.json() - assert data["balance"] == user_balance.balance - assert data["locked_amount"] == 2002.4666666666667 + assert data["balance"] == str(user_balance.balance) + assert data["locked_amount"] == '2002.4666666666667' diff --git a/tests/api/test_list_messages.py b/tests/api/test_list_messages.py index 2659387b..b191e3a7 100644 --- a/tests/api/test_list_messages.py +++ b/tests/api/test_list_messages.py @@ -70,9 +70,7 @@ async def test_get_messages(fixture_messages: Sequence[Dict[str, Any]], ccn_api_ @pytest.mark.asyncio async def test_get_messages_filter_by_channel(fixture_messages, ccn_api_client): async def fetch_messages_by_channel(channel: str) -> Dict: - response = await ccn_api_client.get( - MESSAGES_URI, params={"channels": channel} - ) + response = await ccn_api_client.get(MESSAGES_URI, params={"channels": channel}) assert response.status == 200, await response.text() return await response.json() @@ -194,9 +192,7 @@ async def test_get_messages_filter_by_tags( assert len(messages) == 2 # Matching tags for both messages - response = await ccn_api_client.get( - MESSAGES_URI, params={"tags": "original,amend"} - ) + response = await ccn_api_client.get(MESSAGES_URI, params={"tags": "original,amend"}) assert response.status == 200, await response.text() messages = (await response.json())["messages"] assert len(messages) == 2 diff --git a/tests/api/test_posts.py b/tests/api/test_posts.py index b63cb770..bd0e7b44 100644 --- a/tests/api/test_posts.py +++ b/tests/api/test_posts.py @@ -261,9 +261,7 @@ async def test_get_amended_posts_tags( session.commit() # Match one tag - response = await ccn_api_client.get( - "/api/v0/posts.json", params={"tags": "amend"} - ) + response = await ccn_api_client.get("/api/v0/posts.json", params={"tags": "amend"}) assert response.status == 200 response_json = await response.json() assert len(response_json["posts"]) == 1 diff --git a/tests/chains/test_chain_data_service.py b/tests/chains/test_chain_data_service.py index b41c0bf5..722d8573 100644 --- a/tests/chains/test_chain_data_service.py +++ b/tests/chains/test_chain_data_service.py @@ -1,4 +1,5 @@ import datetime as dt +import json import pytest from aleph_message.models import ( @@ -135,7 +136,7 @@ async def test_smart_contract_protocol_regular_message( timestamp=1668611900, addr="KT1VBeLD7hzKpj17aRJ3Kc6QQFeikCEXi7W6", msgtype="POST", - msgcontent=content.json(), + msgcontent=json.dumps(content.model_dump()), ) tx = ChainTxDb( @@ -146,7 +147,7 @@ async def test_smart_contract_protocol_regular_message( publisher="KT1BfL57oZfptdtMFZ9LNakEPvuPPA2urdSW", protocol=ChainSyncProtocol.SMART_CONTRACT, protocol_version=1, - content=payload.model_dump(), + content=payload.model_dump(mode="json"), ) chain_data_service = ChainDataService(