Skip to content

Commit 1e4d83c

Browse files
committed
Fix: parse refs and hashes fields correctly for messages API (#346)
Problem: the new validation system did not parse the `refs` and `hashes` list parameters correctly. Solution: apply the list validator to these fields as well.
1 parent d9fca73 commit 1e4d83c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/aleph/web/controllers/messages.py

+2
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@ def validate_field_dependencies(cls, values):
8383

8484
@validator(
8585
"addresses",
86+
"refs",
8687
"content_hashes",
8788
"content_keys",
8889
"content_types",
8990
"chains",
9091
"channels",
9192
"tags",
93+
"hashes",
9294
pre=True,
9395
)
9496
def split_str(cls, v):

tests/api/test_messages.py

+12
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ async def test_get_messages_filter_by_content_hash(fixture_messages, ccn_api_cli
132132
)
133133

134134

135+
@pytest.mark.asyncio
136+
async def test_get_messages_multiple_hashes(fixture_messages, ccn_api_client):
137+
hashes = [
138+
"2953f0b52beb79fc0ed1bc455346fdcb530611605e16c636778a0d673d7184af",
139+
"bc411ae2ba89289458d0168714457e7c9394a29ca83159240585591f4f46444a",
140+
]
141+
response = await ccn_api_client.get(MESSAGES_URI, params={"hashes": ",".join(hashes)})
142+
assert response.status == 200, await response.text()
143+
messages = (await response.json())["messages"]
144+
assert len(messages) == 2
145+
146+
135147
@pytest.mark.asyncio
136148
async def test_get_messages_filter_by_invalid_content_hash(
137149
fixture_messages, ccn_api_client

0 commit comments

Comments
 (0)