diff --git a/src/node/waku_node.py b/src/node/waku_node.py index db4cbe3d..31c0cd2f 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -77,6 +77,8 @@ class WakuNode: "metrics-logging": "true", } default_args.update(nwaku_args) + else: + raise NotImplemented("Not implemented for this node type") for key, value in kwargs.items(): key = key.replace("_", "-") diff --git a/src/steps/filter.py b/src/steps/filter.py index b85160fb..01421520 100644 --- a/src/steps/filter.py +++ b/src/steps/filter.py @@ -21,6 +21,12 @@ class StepsFilter: second_content_topic = "/test/2/waku-filter/proto" test_payload = "Filter works!!" + @pytest.fixture(scope="function", autouse=True) + def filter_setup(self): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") + self.main_nodes = [] + self.optional_nodes = [] + @pytest.fixture(scope="function") def setup_main_relay_node(self): logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") @@ -31,8 +37,7 @@ class StepsFilter: logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") self.node2 = WakuNode(NODE_2, f"node2_{self.test_id}") self.node2.start(relay="false", filter="true", discv5_bootstrap_node=self.enr_uri, filternode=self.multiaddr_with_id) - self.main_nodes = [self.node2] - self.optional_nodes = [] + self.main_nodes.append(self.node2) @pytest.fixture(scope="function") def subscribe_main_nodes(self): @@ -60,10 +65,6 @@ class StepsFilter: self.multiaddr_with_id = self.node1.get_multiaddr_with_id() def setup_optional_filter_nodes(self, node_list=ADDITIONAL_NODES): - try: - self.optional_nodes - except AttributeError: - self.optional_nodes = [] if node_list: nodes = [node.strip() for node in node_list.split(",") if node] else: @@ -102,7 +103,7 @@ class StepsFilter: self.check_published_message_reaches_filter_peer(message=message, pubsub_topic=pubsub_topic, peer_list=peer_list) raise AssertionError("Publish with no subscription worked!!!") except Exception as ex: - assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex) + assert "Bad Request" in str(ex) or "Not Found" in str(ex) or "couldn't find any messages" in str(ex) @retry(stop=stop_after_delay(30), wait=wait_fixed(1), reraise=True) @allure.step @@ -134,15 +135,23 @@ class StepsFilter: def update_filter_subscription(self, subscription, node=None): if node is None: node = self.node2 + if node.is_gowaku(): + pytest.skip(f"This method doesn't exist for node {node.type()}") return node.update_filter_subscriptions(subscription) @allure.step - def delete_filter_subscription(self, subscription, node=None): + def delete_filter_subscription(self, subscription, status=None, node=None): if node is None: node = self.node2 delete_sub_response = node.delete_filter_subscriptions(subscription) - assert delete_sub_response["requestId"] == subscription["requestId"] - assert delete_sub_response["statusDesc"] in ["OK", ""] # until https://github.com/waku-org/nwaku/issues/2286 is fixed + if node.is_gowaku() and "requestId" not in subscription: + assert delete_sub_response["requestId"] == "" + else: + assert delete_sub_response["requestId"] == subscription["requestId"] + if status is None: + assert delete_sub_response["statusDesc"] in ["OK", ""] # until https://github.com/waku-org/nwaku/issues/2286 is fixed + else: + assert status in delete_sub_response["statusDesc"] @allure.step def delete_all_filter_subscriptions(self, request_id, node=None): @@ -172,8 +181,10 @@ class StepsFilter: node = self.node2 if node.is_gowaku(): return node.get_filter_messages(content_topic, pubsub_topics) - else: + elif node.is_nwaku(): return node.get_filter_messages(content_topic) + else: + raise NotImplemented("Not implemented for this node type") @allure.step def create_message(self, **kwargs): diff --git a/src/steps/relay.py b/src/steps/relay.py index 6324af5e..b59684a3 100644 --- a/src/steps/relay.py +++ b/src/steps/relay.py @@ -18,6 +18,12 @@ class StepsRelay: test_content_topic = "/test/1/waku-relay/proto" test_payload = "Relay works!!" + @pytest.fixture(scope="function", autouse=True) + def relay_setup(self): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") + self.main_nodes = [] + self.optional_nodes = [] + @pytest.fixture(scope="function") def setup_main_relay_nodes(self, request): logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") @@ -26,8 +32,7 @@ class StepsRelay: self.enr_uri = self.node1.get_enr_uri() self.node2 = WakuNode(NODE_2, f"node2_{request.cls.test_id}") self.node2.start(relay="true", discv5_bootstrap_node=self.enr_uri) - self.main_nodes = [self.node1, self.node2] - self.optional_nodes = [] + self.main_nodes.extend([self.node1, self.node2]) @pytest.fixture(scope="function") def setup_optional_relay_nodes(self, request): diff --git a/src/test_data.py b/src/test_data.py index a4ce6fe1..1a86351d 100644 --- a/src/test_data.py +++ b/src/test_data.py @@ -68,15 +68,10 @@ INVALID_CONTENT_TOPICS = [ VALID_PUBSUB_TOPICS = [ DEFAULT_PUBSUB_TOPIC, "/waku/2/rs/0/1", - "/test/2/rs/0/1", - "/waku/3/rs/0/1", - "/waku/2/test/0/1", "/waku/2/rs/0/50", - "/waku/18/50", - "test", ] -INVALID_PUBSUB_TOPICS = ["/test/2/rs/18/1", ("/waku/2/rs/18/1"), {"pubsub_topic": "/waku/3/rs/18/1"}, True, 12345678, [["/waku/2/rs/18/1"]]] +INVALID_PUBSUB_TOPICS = ["/test/2/rs/0/1", "/waku/3/rs/0/1", "/waku/2/test/0/1", "/waku/2/rs/0/b", "/waku/2/rs/0"] SAMPLE_TIMESTAMPS = [ diff --git a/tests/filter/test_idle_subscriptions.py b/tests/filter/test_idle_subscriptions.py index 12519309..c1e90400 100644 --- a/tests/filter/test_idle_subscriptions.py +++ b/tests/filter/test_idle_subscriptions.py @@ -8,6 +8,7 @@ from src.steps.metrics import StepsMetrics logger = get_custom_logger(__name__) +@pytest.mark.skip(reason="Skipping until https://github.com/waku-org/nwaku/issues/2293 is fixed") class TestIdleSubscriptions(StepsFilter, StepsMetrics): @pytest.mark.timeout(60 * 10) def test_idle_filter_subscriptions_for_more_than_5_nodes(self): diff --git a/tests/filter/test_subscribe_create.py b/tests/filter/test_subscribe_create.py index 58f12e7e..19e439e9 100644 --- a/tests/filter/test_subscribe_create.py +++ b/tests/filter/test_subscribe_create.py @@ -90,7 +90,12 @@ class TestFilterSubscribeUpdate(StepsFilter): def test_filter_subscribe_with_no_content_topic(self, subscribe_main_nodes): try: self.create_filter_subscription({"requestId": "1", "pubsubTopic": self.test_pubsub_topic}) - raise AssertionError("Subscribe with no content topics worked!!!") + if self.node2.is_nwaku(): + raise AssertionError("Subscribe with extra field worked!!!") + elif self.node2.is_gowaku(): + pass + else: + raise NotImplemented("Not implemented for this node type") except Exception as ex: assert "Bad Request" in str(ex) @@ -124,6 +129,11 @@ class TestFilterSubscribeUpdate(StepsFilter): self.create_filter_subscription( {"requestId": "1", "contentFilters": [self.test_content_topic], "pubsubTopic": self.test_pubsub_topic, "extraField": "extraValue"} ) - raise AssertionError("Subscribe with extra field worked!!!") + if self.node2.is_nwaku(): + raise AssertionError("Subscribe with extra field worked!!!") + elif self.node2.is_gowaku(): + pass + else: + raise NotImplemented("Not implemented for this node type") except Exception as ex: assert "Bad Request" in str(ex) diff --git a/tests/filter/test_unsubscribe.py b/tests/filter/test_unsubscribe.py index d3266b93..47a5d3ee 100644 --- a/tests/filter/test_unsubscribe.py +++ b/tests/filter/test_unsubscribe.py @@ -38,13 +38,22 @@ class TestFilterUnSubscribe(StepsFilter): self.check_publish_without_filter_subscription(self.create_message(contentTopic=self.second_content_topic), self.second_pubsub_topic) def test_filter_unsubscribe_from_non_existing_content_topic(self): - self.delete_filter_subscription({"requestId": "1", "contentFilters": [self.second_content_topic], "pubsubTopic": self.test_pubsub_topic}) + self.delete_filter_subscription( + {"requestId": "1", "contentFilters": [self.second_content_topic], "pubsubTopic": self.test_pubsub_topic}, status="can't unsubscribe" + ) self.check_published_message_reaches_filter_peer() def test_filter_unsubscribe_from_non_existing_pubsub_topic(self): try: - self.delete_filter_subscription({"requestId": "1", "contentFilters": [self.test_pubsub_topic], "pubsubTopic": self.second_pubsub_topic}) - raise AssertionError("Unsubscribe with non existing pubsub topic worked!!!") + self.delete_filter_subscription( + {"requestId": "1", "contentFilters": [self.test_pubsub_topic], "pubsubTopic": self.second_pubsub_topic}, status="can't unsubscribe" + ) + if self.node2.is_nwaku(): + raise AssertionError("Unsubscribe with non existing pubsub topic worked!!!") + elif self.node2.is_gowaku(): + pass + else: + raise NotImplemented("Not implemented for this node type") except Exception as ex: assert "Not Found" and "peer has no subscriptions" in str(ex) self.check_published_message_reaches_filter_peer() @@ -99,8 +108,15 @@ class TestFilterUnSubscribe(StepsFilter): def test_filter_unsubscribe_with_no_request_id(self): try: - self.delete_filter_subscription({"contentFilters": [self.test_content_topic], "pubsubTopic": self.test_pubsub_topic}) - raise AssertionError("Unsubscribe with no request id worked!!!") + self.delete_filter_subscription( + {"contentFilters": [self.test_content_topic], "pubsubTopic": self.test_pubsub_topic}, status="can't unsubscribe" + ) + if self.node2.is_nwaku(): + raise AssertionError("Unsubscribe with no request id worked!!!") + elif self.node2.is_gowaku(): + pass + else: + raise NotImplemented("Not implemented for this node type") except Exception as ex: assert "Bad Request" in str(ex) @@ -116,7 +132,12 @@ class TestFilterUnSubscribe(StepsFilter): self.delete_filter_subscription( {"requestId": "1", "contentFilters": [self.test_content_topic], "pubsubTopic": self.test_pubsub_topic, "extraField": "extraValue"} ) - raise AssertionError("Unsubscribe with extra field worked!!!") + if self.node2.is_nwaku(): + raise AssertionError("Unsubscribe with extra field worked!!!") + elif self.node2.is_gowaku(): + pass + else: + raise NotImplemented("Not implemented for this node type") except Exception as ex: assert "Bad Request" in str(ex) diff --git a/tests/filter/test_unsubscribe_all.py b/tests/filter/test_unsubscribe_all.py index 341d09ac..3abf8816 100644 --- a/tests/filter/test_unsubscribe_all.py +++ b/tests/filter/test_unsubscribe_all.py @@ -4,7 +4,7 @@ from src.steps.filter import StepsFilter from random import choice -@pytest.mark.usefixtures("setup_main_relay_node", "setup_main_filter_node", "filter_warm_up") +@pytest.mark.usefixtures("setup_main_relay_node", "setup_main_filter_node") class TestFilterUnSubscribeAll(StepsFilter): def test_filter_unsubscribe_all_from_few_content_topics(self): content_topics = [input["value"] for input in SAMPLE_INPUTS[:5]] @@ -45,14 +45,12 @@ class TestFilterUnSubscribeAll(StepsFilter): self.delete_all_filter_subscriptions({"requestId": "1"}) raise AssertionError("Unsubscribe all on peer without subscriptions worked!!!") except Exception as ex: - assert "Not Found" and "peer has no subscriptions" in str(ex) - - def test_filter_unsubscribe_all_with_no_request_id(self, subscribe_main_nodes): - try: - self.delete_all_filter_subscriptions({}) - raise AssertionError("Unsubscribe all with no request id worked!!!") - except Exception as ex: - assert "Bad Request" in str(ex) + if self.node2.is_nwaku(): + assert "Not Found" and "peer has no subscriptions" in str(ex) + elif self.node2.is_gowaku(): + assert "subscription not found" in str(ex) + else: + raise NotImplemented("Not implemented for this node type") def test_filter_unsubscribe_all_with_invalid_request_id(self, subscribe_main_nodes): try: @@ -61,7 +59,7 @@ class TestFilterUnSubscribeAll(StepsFilter): except Exception as ex: assert "Bad Request" in str(ex) - def test_filter_unsubscribe_all_with_extra_field(self): + def test_filter_unsubscribe_all_with_extra_field(self, subscribe_main_nodes): try: self.delete_all_filter_subscriptions({"requestId": 1, "extraField": "extraValue"}) raise AssertionError("Unsubscribe all with extra field worked!!!") diff --git a/tests/relay/test_publish.py b/tests/relay/test_publish.py index 5e94f961..757210b5 100644 --- a/tests/relay/test_publish.py +++ b/tests/relay/test_publish.py @@ -44,7 +44,7 @@ class TestRelayPublish(StepsRelay): assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex) def test_publish_with_payload_less_than_one_mb(self): - payload_length = 1024 * 1023 + payload_length = 1024 * 700 # after encoding to base64 this be close to 1MB logger.debug(f"Running test with payload length of {payload_length} bytes") message = self.create_message(payload=to_base64("a" * (payload_length))) self.check_published_message_reaches_relay_peer(message, message_propagation_delay=2) @@ -187,7 +187,16 @@ class TestRelayPublish(StepsRelay): self.check_published_message_reaches_relay_peer(self.create_message(rateLimitProof=rate_limit_proof)) def test_publish_with_extra_field(self): - self.check_published_message_reaches_relay_peer(self.create_message(extraField="extraValue")) + try: + self.check_published_message_reaches_relay_peer(self.create_message(extraField="extraValue")) + if self.node1.is_nwaku(): + raise AssertionError("Relay publish with extra field worked!!!") + elif self.node1.is_gowaku(): + pass + else: + raise NotImplemented("Not implemented for this node type") + except Exception as ex: + assert "Bad Request" in str(ex) def test_publish_and_retrieve_duplicate_message(self): message = self.create_message() diff --git a/tests/relay/test_subscribe.py b/tests/relay/test_subscribe.py index 5d92d345..3036e4fb 100644 --- a/tests/relay/test_subscribe.py +++ b/tests/relay/test_subscribe.py @@ -76,7 +76,7 @@ class TestRelaySubscribe(StepsRelay): elif self.node1.is_gowaku(): raise AssertionError("Unsubscribe from non-subscribed pubsub_topic worked!!!") else: - raise Exception("Not implemented") + raise NotImplemented("Not implemented for this node type") except Exception as ex: assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex) self.check_published_message_reaches_relay_peer()