Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6ed6404
adding test "test_store_not_include_data"
AYAHASSAN287 Oct 15, 2024
81b0f20
adding test case for wrong peer address formatting
AYAHASSAN287 Oct 15, 2024
edf12b9
try restore message with wrong peer id
AYAHASSAN287 Oct 15, 2024
9ce4b24
send peer address with wrong protocol
AYAHASSAN287 Oct 15, 2024
6effb21
Fixing review comments & add test for wrong topic
AYAHASSAN287 Oct 15, 2024
f7187be
adding test for topic content positive scenario
AYAHASSAN287 Oct 16, 2024
8b042de
adding test for different wrong content topic
AYAHASSAN287 Oct 16, 2024
2c3d84d
adding content topic & pubsubtopic tests
AYAHASSAN287 Oct 17, 2024
7f397ba
adding test cases for wrong encoding 7 no encoding of pubsub topic
AYAHASSAN287 Oct 17, 2024
7eed478
adding test case test_time_filter_start_time_after_end_time
AYAHASSAN287 Oct 17, 2024
b80118d
adding more time tests
AYAHASSAN287 Oct 20, 2024
a62e204
adding tests with wrong start & end time
AYAHASSAN287 Oct 20, 2024
8deaaf9
adding invalid ascending test
AYAHASSAN287 Oct 20, 2024
542fc00
adding page_size tests
AYAHASSAN287 Oct 22, 2024
d0bde7b
adding invalid ascending test
AYAHASSAN287 Oct 22, 2024
15472c6
fix minor issues and adding comments
AYAHASSAN287 Oct 22, 2024
ffd8d5b
fixing review comments
AYAHASSAN287 Oct 22, 2024
e3405e5
minor change in test name
AYAHASSAN287 Oct 22, 2024
bb841c1
Merge branch 'waku_edge_tests_part3' into WAKU_edge_tests
AYAHASSAN287 Oct 23, 2024
3a7484e
Merge branch 'waku_edge_tests_part2' into WAKU_edge_tests
AYAHASSAN287 Oct 24, 2024
82a2c0a
Merge branch 'master' into WAKU_edge_tests
AYAHASSAN287 Oct 24, 2024
a7b61ae
Adding review comments
AYAHASSAN287 Oct 24, 2024
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: 2 additions & 2 deletions src/node/store_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def message_hash(self, index):
else:
return None

def message_payload(self, index):
def message_content(self, index):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method was used in other places, please either:

  • create a new method and leave message_payload
  • update any other places where message_payload was used to use message_content

try:
if self.messages is not None:
payload = self.messages[index]["message"]["payload"]
payload = self.messages[index]["message"]["contentTopic"]
return payload
else:
return None
Expand Down
69 changes: 69 additions & 0 deletions tests/store/test_api_flags.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import pytest
from time import time
from src.libs.custom_logger import get_custom_logger
from src.libs.common import to_base64
from src.node.waku_message import WakuMessage
from src.node.store_response import StoreResponse
from src.steps.store import StepsStore
from src.test_data import SAMPLE_INPUTS
from src.test_data import PUBSUB_TOPICS_STORE

logger = get_custom_logger(__name__)


@pytest.mark.usefixtures("node_setup")
Expand All @@ -11,6 +17,36 @@ def test_store_with_peerAddr(self):
self.publish_message()
self.check_published_message_is_stored(store_node=self.store_node1, peer_addr=self.multiaddr_list[0])

def test_store_with_wrongPeerAddr(self):
self.publish_message()
wrong_peer_addr = self.multiaddr_list[0][1:]
logger.debug(f"Running test with wrong_peer_addr: {wrong_peer_addr}")
try:
self.check_published_message_is_stored(store_node=self.store_node1, peer_addr=wrong_peer_addr)
raise Exception("Message stored with wrong peer address")
except Exception as ex:
logger.debug(f" Response with wrong peer address is { ex.args[0]}")
assert ex.args[0].find("Invalid MultiAddress") != -1
# try to send wrong peer id
wrong_peer_id = self.multiaddr_list[0][:-1]
logger.debug(f"Running test with wrong_peer_addr {wrong_peer_id}")
try:
self.check_published_message_is_stored(store_node=self.store_node1, peer_addr=wrong_peer_id)
raise Exception("Message restored with wrong peer id")
except Exception as ex:
logger.debug(f" Response with wrong peer id is { ex.args[0]}")
assert ex.args[0].find("Failed parsing remote peer info") != -1

# send address without /tcp number
wrong_peer_addr = self.multiaddr_list[0].replace("/tcp", "")
logger.debug(f"logger is {wrong_peer_addr}")
try:
self.check_published_message_is_stored(store_node=self.store_node1, peer_addr=wrong_peer_addr)
raise Exception("Message stored with wrong peer address")
except Exception as ex:
logger.debug(f" Response with wrong peer address is { ex.args[0]}")
assert ex.args[0].find("Unsupported protocol") != -1

def test_store_include_data(self):
message_list = []
for payload in SAMPLE_INPUTS:
Expand All @@ -25,3 +61,36 @@ def test_store_include_data(self):
assert store_response.message_pubsub_topic(index) == self.test_pubsub_topic
waku_message = WakuMessage([store_response.message_at(index)])
waku_message.assert_received_message(message_list[index])

def test_store_not_include_data(self):
self.publish_message(message=self.create_message())
store_response = self.get_messages_from_store(self.store_node1, include_data="false")
logger.debug(f" Message restored with hash only is {store_response.messages} ")
assert "message" not in store_response.messages

def test_get_store_messages_with_different_pubsub_topics11(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong_topic = PUBSUB_TOPICS_STORE[0][:-1]
logger.debug(f"Trying to get stored msg with wrong topic")
try:
self.publish_message(pubsub_topic=PUBSUB_TOPICS_STORE[0])
self.check_published_message_is_stored(pubsub_topic=wrong_topic)
raise Exception("Message stored with wrong peer topic")
except Exception as e:
logger.error(f"Topic {wrong_topic} is wrong ''n: {str(e)}")
assert e.args[0].find("messages': []") != -1, "Message shall not be stored for wrong topic"

def test_get_store_messages_with_content_topic(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# positive scenario
content_topic = "/myapp/1/latest/protoo"
message = {"payload": to_base64(self.test_payload), "" "contentTopic": content_topic, "timestamp": int(time() * 1e9)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use create_message ex
message = self.create_message(contentTopic=content_topic)

logger.debug(f"Trying to publish msg with content topic {content_topic}")
msg = self.publish_message(message=message)
store_response = self.get_messages_from_store(self.store_node1, include_data="true", content_topics=content_topic)
try:
if store_response.messages is not None:
stored_contentTopic = store_response.message_content(0)
logger.debug(f"stored content topic is {stored_contentTopic}")
assert stored_contentTopic == content_topic, "content topics don't match"

except Exception as e:
raise Exception(f"can't get message with content topic {content_topic}")