mirror of
https://github.com/logos-messaging/logos-messaging-interop-tests.git
synced 2026-05-01 08:03:29 +00:00
first commit
This commit is contained in:
parent
d0a84b2009
commit
2086584df8
@ -1,3 +1,5 @@
|
|||||||
|
import base64
|
||||||
|
import hashlib
|
||||||
import inspect
|
import inspect
|
||||||
from time import time
|
from time import time
|
||||||
import allure
|
import allure
|
||||||
@ -34,3 +36,15 @@ class StepsCommon:
|
|||||||
message = {"payload": to_base64(self.test_payload), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)}
|
message = {"payload": to_base64(self.test_payload), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)}
|
||||||
message.update(kwargs)
|
message.update(kwargs)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
@allure.step
|
||||||
|
def compute_message_hash(self, pubsub_topic, msg):
|
||||||
|
ctx = hashlib.sha256()
|
||||||
|
ctx.update(pubsub_topic.encode("utf-8"))
|
||||||
|
payload_bytes = base64.b64decode(msg["payload"])
|
||||||
|
ctx.update(payload_bytes)
|
||||||
|
ctx.update(msg["contentTopic"].encode("utf-8"))
|
||||||
|
timestamp_bytes = int(msg["timestamp"]).to_bytes(8, byteorder="big")
|
||||||
|
ctx.update(timestamp_bytes)
|
||||||
|
hash_bytes = ctx.digest()
|
||||||
|
return base64.b64encode(hash_bytes).decode("utf-8")
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
import inspect
|
import inspect
|
||||||
from src.libs.custom_logger import get_custom_logger
|
from src.libs.custom_logger import get_custom_logger
|
||||||
from time import time
|
|
||||||
import pytest
|
import pytest
|
||||||
import allure
|
import allure
|
||||||
from src.libs.common import to_base64, delay
|
from src.libs.common import delay
|
||||||
from src.node.waku_message import MessageRpcResponse, MessageRpcResponseStore, WakuMessage
|
from src.node.waku_message import MessageRpcResponse, MessageRpcResponseStore, WakuMessage
|
||||||
from src.env_vars import (
|
from src.env_vars import (
|
||||||
ADDITIONAL_NODES,
|
ADDITIONAL_NODES,
|
||||||
@ -138,7 +137,7 @@ class StepsStore(StepsCommon):
|
|||||||
cursor=None,
|
cursor=None,
|
||||||
pageSize=None,
|
pageSize=None,
|
||||||
ascending=None,
|
ascending=None,
|
||||||
store_v="v1",
|
store_v="v3",
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
if store_node is None:
|
if store_node is None:
|
||||||
@ -165,12 +164,19 @@ class StepsStore(StepsCommon):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert "messages" in self.store_response, f"Peer {node.image} has no messages key in the reponse"
|
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 self.store_response["messages"], f"Peer {node.image} couldn't find any messages. Actual response: {self.store_response}"
|
||||||
assert len(self.store_response["messages"]) >= 1, "Expected at least 1 message but got none"
|
assert len(self.store_response["messages"]) >= 1, "Expected at least 1 message but got none"
|
||||||
|
store_message_index = -1 # we are looking for the last and most recent message in the store
|
||||||
waku_message = WakuMessage(
|
waku_message = WakuMessage(
|
||||||
self.store_response["messages"][-1:], schema=MessageRpcResponseStore if node.is_nwaku() else MessageRpcResponse
|
self.store_response["messages"][store_message_index:], schema=MessageRpcResponseStore if node.is_nwaku() else MessageRpcResponse
|
||||||
)
|
)
|
||||||
waku_message.assert_received_message(self.message)
|
if store_v == "v1":
|
||||||
|
waku_message.assert_received_message(self.message)
|
||||||
|
else:
|
||||||
|
assert (
|
||||||
|
self.compute_message_hash(pubsubTopic, self.message)
|
||||||
|
== self.store_response["messages"][store_message_index]["message_hash"]["data"]
|
||||||
|
)
|
||||||
|
|
||||||
@allure.step
|
@allure.step
|
||||||
def check_store_returns_empty_response(self, pubsub_topic=None):
|
def check_store_returns_empty_response(self, pubsub_topic=None):
|
||||||
|
|||||||
@ -28,3 +28,7 @@ class TestGetMessages(StepsStore):
|
|||||||
logger.error(f'Payload {payload["description"]} failed: {str(e)}')
|
logger.error(f'Payload {payload["description"]} failed: {str(e)}')
|
||||||
failed_payloads.append(payload["description"])
|
failed_payloads.append(payload["description"])
|
||||||
assert not failed_payloads, f"Payloads failed: {failed_payloads}"
|
assert not failed_payloads, f"Payloads failed: {failed_payloads}"
|
||||||
|
|
||||||
|
def test_store_v1(self):
|
||||||
|
self.publish_message_via("relay")
|
||||||
|
self.check_published_message_is_stored(pubsubTopic=self.test_pubsub_topic, pageSize=5, ascending="true", store_v="v1")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user