From 931f9cf66470d223c4e9c823c1161d1bcb6761ef Mon Sep 17 00:00:00 2001 From: Florin Barbu Date: Tue, 28 May 2024 14:04:38 +0300 Subject: [PATCH] adjsutmens for go-waku --- src/steps/store.py | 9 +++++++-- tests/store/test_cursor.py | 10 +++++----- tests/store/test_hashes.py | 18 ++++++++++++------ tests/store/test_topics.py | 2 +- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/steps/store.py b/src/steps/store.py index 9a1cb099..685a5094 100644 --- a/src/steps/store.py +++ b/src/steps/store.py @@ -150,8 +150,13 @@ class StepsStore(StepsCommon): ): if pubsub_topic is None: pubsub_topic = self.test_pubsub_topic - if node.is_gowaku() and content_topics is None: - content_topics = self.test_content_topic + if node.is_gowaku(): + if content_topics is None: + content_topics = self.test_content_topic + if hashes is not None: + content_topics = None + pubsub_topic = None + peer_addr = self.multiaddr_list[0] store_response = node.get_store_messages( peer_addr=peer_addr, include_data=include_data, diff --git a/tests/store/test_cursor.py b/tests/store/test_cursor.py index 423581af..695fca06 100644 --- a/tests/store/test_cursor.py +++ b/tests/store/test_cursor.py @@ -5,7 +5,7 @@ from src.node.store_response import StoreResponse from src.steps.store import StepsStore -@pytest.mark.xfail("go_waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1109") +@pytest.mark.xfail("go-waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1109") @pytest.mark.usefixtures("node_setup") class TestCursor(StepsStore): # we implicitly test the reusabilty of the cursor for multiple nodes @@ -67,7 +67,7 @@ class TestCursor(StepsStore): cursor = store_response.message_hash(9) for node in self.store_nodes: store_response = self.get_messages_from_store(node, page_size=100, cursor=cursor) - assert len(store_response.messages) == 0, "Message count mismatch" + assert not store_response.messages, "Messages found" @pytest.mark.xfail("go-waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1110") @pytest.mark.xfail("nwaku" in (NODE_1 + NODE_2), reason="Bug reported: https://github.com/waku-org/nwaku/issues/2716") @@ -79,7 +79,7 @@ class TestCursor(StepsStore): cursor = self.compute_message_hash(self.test_pubsub_topic, wrong_message) for node in self.store_nodes: store_response = self.get_messages_from_store(node, page_size=100, cursor=cursor) - assert len(store_response.messages) == 0, "Message count mismatch" + assert not store_response.messages, "Messages found" @pytest.mark.xfail("go-waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1110") @pytest.mark.xfail("nwaku" in (NODE_1 + NODE_2), reason="Bug reported: https://github.com/waku-org/nwaku/issues/2716") @@ -90,7 +90,7 @@ class TestCursor(StepsStore): cursor = to_base64("test") for node in self.store_nodes: store_response = self.get_messages_from_store(node, page_size=100, cursor=cursor) - assert len(store_response.messages) == 0, "Message count mismatch" + assert not store_response.messages, "Messages found" @pytest.mark.xfail("go-waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1110") @pytest.mark.xfail("nwaku" in (NODE_1 + NODE_2), reason="Bug reported: https://github.com/waku-org/nwaku/issues/2716") @@ -101,4 +101,4 @@ class TestCursor(StepsStore): cursor = "test" for node in self.store_nodes: store_response = self.get_messages_from_store(node, page_size=100, cursor=cursor) - assert len(store_response.messages) == 0, "Message count mismatch" + assert not store_response.messages, "Messages found" diff --git a/tests/store/test_hashes.py b/tests/store/test_hashes.py index 5487f117..51528b4b 100644 --- a/tests/store/test_hashes.py +++ b/tests/store/test_hashes.py @@ -8,7 +8,7 @@ from src.test_data import SAMPLE_INPUTS logger = get_custom_logger(__name__) -@pytest.mark.xfail("go_waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1109") +@pytest.mark.xfail("go-waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1109") @pytest.mark.usefixtures("node_setup") class TestHashes(StepsStore): def test_store_with_hashes(self): @@ -41,20 +41,26 @@ class TestHashes(StepsStore): wrong_hash = self.compute_message_hash(self.test_pubsub_topic, self.create_message(payload=to_base64("test"))) for node in self.store_nodes: store_response = self.get_messages_from_store(node, hashes=wrong_hash, page_size=50) - assert len(store_response.messages) == 0 + assert not store_response.messages, "Messages found" def test_store_with_invalid_hash(self): for i in range(4): self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}"))) invalid_hash = to_base64("test") for node in self.store_nodes: - store_response = self.get_messages_from_store(node, hashes=invalid_hash, page_size=50) - assert len(store_response.messages) == 0 + try: + store_response = self.get_messages_from_store(node, hashes=invalid_hash, page_size=50) + assert not store_response.messages + except Exception as ex: + assert "waku message hash parsing error: invalid hash length" in str(ex) def test_store_with_non_base64_hash(self): for i in range(4): self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}"))) non_base64_hash = "test" for node in self.store_nodes: - store_response = self.get_messages_from_store(node, hashes=non_base64_hash, page_size=50) - assert len(store_response.messages) == 0 + try: + store_response = self.get_messages_from_store(node, hashes=non_base64_hash, page_size=50) + assert not store_response.messages + except Exception as ex: + assert "waku message hash parsing error: invalid hash length" in str(ex) diff --git a/tests/store/test_topics.py b/tests/store/test_topics.py index 8c93d748..fc315c01 100644 --- a/tests/store/test_topics.py +++ b/tests/store/test_topics.py @@ -4,7 +4,7 @@ from src.steps.store import StepsStore from src.test_data import CONTENT_TOPICS_DIFFERENT_SHARDS -@pytest.mark.xfail("go_waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1108") +@pytest.mark.xfail("go-waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1108") class TestTopics(StepsStore): @pytest.fixture(scope="function", autouse=True) def topics_setup(self, node_setup):