temp store content topic fix (#37)

* temp sote content topic fix

* fix go-waku
This commit is contained in:
fbarbu15 2024-05-13 15:14:14 +03:00 committed by GitHub
parent b9ec0bb1d2
commit d0a84b2009
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 3 deletions

View File

@ -17,6 +17,18 @@ class MessageRpcResponse:
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)
class WakuMessage:
def __init__(self, message_response, schema=MessageRpcResponse):
self.schema = schema
@ -31,7 +43,10 @@ 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")
assert message.contentTopic == sent_message["contentTopic"], assert_fail_message("contentTopic")
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")
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

@ -4,7 +4,7 @@ from time import time
import pytest
import allure
from src.libs.common import to_base64, delay
from src.node.waku_message import WakuMessage
from src.node.waku_message import MessageRpcResponse, MessageRpcResponseStore, WakuMessage
from src.env_vars import (
ADDITIONAL_NODES,
NODE_1,
@ -167,7 +167,9 @@ 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:])
waku_message = WakuMessage(
self.store_response["messages"][-1:], schema=MessageRpcResponseStore if node.is_nwaku() else MessageRpcResponse
)
waku_message.assert_received_message(self.message)
@allure.step