all message fields are now camel case (#40)

This commit is contained in:
fbarbu15 2024-05-20 13:10:53 +03:00 committed by GitHub
parent 73a1711d54
commit 2e9a3d1202
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 22 deletions

View File

@ -13,19 +13,6 @@ class MessageRpcResponse:
timestamp: Optional[int]
ephemeral: Optional[bool]
meta: Optional[str]
rateLimitProof: Optional[Union[dict, str]] = field(default_factory=dict)
rate_limit_proof: Optional[dict] = field(default_factory=dict)
@dataclass
class MessageRpcResponseStore:
payload: str
content_topic: str
version: Optional[int]
timestamp: Optional[int]
ephemeral: Optional[bool]
meta: Optional[str]
rateLimitProof: Optional[Union[dict, str]] = field(default_factory=dict)
rate_limit_proof: Optional[dict] = field(default_factory=dict)
@ -43,10 +30,7 @@ class WakuMessage:
return f"Incorrect field: {field_name}. Published: {sent_message[field_name]} Received: {getattr(message, field_name)}"
assert message.payload == sent_message["payload"], assert_fail_message("payload")
if self.schema == MessageRpcResponse:
assert message.contentTopic == sent_message["contentTopic"], assert_fail_message("contentTopic")
else:
assert message.content_topic == sent_message["contentTopic"], assert_fail_message("content_topic")
assert message.contentTopic == sent_message["contentTopic"], assert_fail_message("contentTopic")
if sent_message.get("timestamp") is not None:
if isinstance(sent_message["timestamp"], float):
assert math.isclose(float(message.timestamp), sent_message["timestamp"], rel_tol=1e-9), assert_fail_message("timestamp")

View File

@ -3,8 +3,8 @@ from src.libs.custom_logger import get_custom_logger
from time import time
import pytest
import allure
from src.libs.common import to_base64, delay
from src.node.waku_message import MessageRpcResponse, MessageRpcResponseStore, WakuMessage
from src.libs.common import delay
from src.node.waku_message import WakuMessage
from src.env_vars import (
ADDITIONAL_NODES,
NODE_1,
@ -167,9 +167,7 @@ class StepsStore(StepsCommon):
assert "messages" in self.store_response, f"Peer {node.image} has no messages key in the reponse"
assert self.store_response["messages"], f"Peer {node.image} couldn't find any messages"
assert len(self.store_response["messages"]) >= 1, "Expected at least 1 message but got none"
waku_message = WakuMessage(
self.store_response["messages"][-1:], schema=MessageRpcResponseStore if node.is_nwaku() else MessageRpcResponse
)
waku_message = WakuMessage(self.store_response["messages"][-1:])
waku_message.assert_received_message(self.message)
@allure.step