-
Notifications
You must be signed in to change notification settings - Fork 1
Chore: store v3 edge test cases #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
6ed6404
81b0f20
edf12b9
9ce4b24
6effb21
f7187be
8b042de
2c3d84d
7f397ba
7eed478
b80118d
a62e204
8deaaf9
542fc00
d0bde7b
15472c6
ffd8d5b
e3405e5
bb841c1
3a7484e
82a2c0a
a7b61ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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") | ||
|
|
@@ -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: | ||
|
|
@@ -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): | ||
|
||
| 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): | ||
|
||
| # positive scenario | ||
| content_topic = "/myapp/1/latest/protoo" | ||
| message = {"payload": to_base64(self.test_payload), "" "contentTopic": content_topic, "timestamp": int(time() * 1e9)} | ||
|
||
| 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}") | ||
There was a problem hiding this comment.
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: