Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/aleph/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ async def check_message(
if not message:
raise InvalidMessageError("Message must not be empty")

if "item_hash" not in message:
raise InvalidMessageError("Missing field 'item_hash' in message")
for field in ("chain", "sender", "signature"):
for field in INCOMING_MESSAGE_AUTHORIZED_FIELDS:
if field not in message:
raise InvalidMessageError(
f"Missing field '{field}' in message {message['item_hash']}"
Expand Down
14 changes: 4 additions & 10 deletions tests/api/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,9 @@ async def fetch_messages_by_channel(channel: str) -> Dict:


@pytest.mark.asyncio
async def test_get_messages_filter_by_chain(fixture_messages, aiohttp_client):
app = create_app()
client = await aiohttp_client(app)

async def test_get_messages_filter_by_chain(fixture_messages, ccn_api_client):
async def fetch_messages_by_chain(chain: str) -> Dict:
response = await client.get(MESSAGES_URI, params={"chains": chain})
response = await ccn_api_client.get(MESSAGES_URI, params={"chains": chain})
assert response.status == 200, await response.text()
return await response.json()

Expand All @@ -114,12 +111,9 @@ async def fetch_messages_by_chain(chain: str) -> Dict:


@pytest.mark.asyncio
async def test_get_messages_filter_by_content_hash(fixture_messages, aiohttp_client):
app = create_app()
client = await aiohttp_client(app)

async def test_get_messages_filter_by_content_hash(fixture_messages, ccn_api_client):
async def fetch_messages_by_content_hash(item_hash: str) -> Dict:
response = await client.get(MESSAGES_URI, params={"contentHashes": item_hash})
response = await ccn_api_client.get(MESSAGES_URI, params={"contentHashes": item_hash})
assert response.status == 200, await response.text()
return await response.json()

Expand Down