diff --git a/src/node/waku_node.py b/src/node/waku_node.py index 44886f95..3c2cad88 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -62,7 +62,7 @@ def multiaddr2id(multiaddr): def resolve_sharding_flags(kwargs): - if "pubsub_topic" in kwargs: + if "pubsub_topic" in kwargs and kwargs["pubsub_topic"]: pubsub_topic = kwargs["pubsub_topic"] if not "cluster_id" in kwargs: try: @@ -152,8 +152,16 @@ class WakuNode: default_args.update(sanitize_docker_flags(kwargs)) - if self.is_gowaku() and default_args.get("relay") == "false": - default_args["pubsub-topic"] = VALID_PUBSUB_TOPICS[1] + if self.is_gowaku(): + if default_args.get("relay") == "false" and "pubsub-topic" not in default_args: + logger.info(f"Adding pubsub-topic={VALID_PUBSUB_TOPICS[1]} to default args for go-waku") + default_args["pubsub-topic"] = VALID_PUBSUB_TOPICS[1] + if "shard" in default_args: + del default_args["shard"] + + if self.is_nwaku() and "pubsub-topic" in default_args: + logger.debug("Removing pubsub-topic from nwaku args") + del default_args["pubsub-topic"] rln_args, rln_creds_set, keystore_path = self.parse_rln_credentials(default_args, False) diff --git a/tests/sharding/test_relay_auto_sharding.py b/tests/sharding/test_relay_auto_sharding.py index e92720f6..735e4907 100644 --- a/tests/sharding/test_relay_auto_sharding.py +++ b/tests/sharding/test_relay_auto_sharding.py @@ -29,7 +29,7 @@ class TestRelayAutosharding(StepsSharding): else: raise AssertionError("Retrieving messages without subscribing worked!!!") except Exception as ex: - assert "Not Found" in str(ex) + assert "Failed to publish: Node not subscribed to topic" in str(ex) def test_subscribe_and_publish_on_another_content_topic_from_same_shard(self): self.setup_main_relay_nodes(cluster_id=self.auto_cluster, content_topic=self.test_content_topic) diff --git a/tests/sharding/test_relay_static_sharding.py b/tests/sharding/test_relay_static_sharding.py index f8802d66..586f6567 100644 --- a/tests/sharding/test_relay_static_sharding.py +++ b/tests/sharding/test_relay_static_sharding.py @@ -9,11 +9,6 @@ logger = get_custom_logger(__name__) class TestRelayStaticSharding(StepsSharding): - def test_publish_without_subscribing_via_api_works(self): - self.setup_main_relay_nodes(pubsub_topic=self.test_pubsub_topic) - for node in self.main_nodes: - self.relay_message(node, self.create_message(), self.test_pubsub_topic) - def test_retrieve_messages_without_subscribing_via_api(self): self.setup_main_relay_nodes(pubsub_topic=self.test_pubsub_topic) try: @@ -23,7 +18,7 @@ class TestRelayStaticSharding(StepsSharding): else: raise AssertionError("Retrieving messages without subscribing worked!!!") except Exception as ex: - assert "Not Found" in str(ex) + assert "no subscription found for pubsubTopic" in str(ex) def test_subscribe_and_publish_on_another_shard(self): self.setup_main_relay_nodes(pubsub_topic=self.test_pubsub_topic) @@ -36,7 +31,7 @@ class TestRelayStaticSharding(StepsSharding): else: raise AssertionError("Retrieving messages without subscribing worked!!!") except Exception as ex: - assert "Not Found" in str(ex) + assert "no subscription found for pubsubTopic" in str(ex) def test_cant_publish_on_not_subscribed_shard(self): self.setup_main_relay_nodes(pubsub_topic=self.test_pubsub_topic) diff --git a/tests/sharding/test_running_nodes_auto_sharding.py b/tests/sharding/test_running_nodes_auto_sharding.py index 37e19795..fd3a7b88 100644 --- a/tests/sharding/test_running_nodes_auto_sharding.py +++ b/tests/sharding/test_running_nodes_auto_sharding.py @@ -58,12 +58,6 @@ class TestRunningNodesAutosharding(StepsSharding): except Exception as ex: assert "Not Found" in str(ex) - @pytest.mark.parametrize("pubsub_topic", ["/waku/2/rs/2/0", "/waku/2/rs/2/1"]) - def test_pubsub_topic_also_in_docker_flags(self, pubsub_topic): - self.setup_main_relay_nodes(cluster_id=self.auto_cluster, pubsub_topic=pubsub_topic, content_topic=self.test_content_topic) - self.subscribe_main_relay_nodes(content_topics=[self.test_content_topic]) - self.check_published_message_reaches_relay_peer(content_topic=self.test_content_topic) - def test_content_topic_not_in_docker_flags(self): self.setup_main_relay_nodes(cluster_id=2, pubsub_topic=self.test_pubsub_topic) self.subscribe_main_relay_nodes(content_topics=[self.test_content_topic]) diff --git a/tests/sharding/test_running_nodes_static_sharding.py b/tests/sharding/test_running_nodes_static_sharding.py index dd1ec084..0f69bd9a 100644 --- a/tests/sharding/test_running_nodes_static_sharding.py +++ b/tests/sharding/test_running_nodes_static_sharding.py @@ -10,7 +10,7 @@ logger = get_custom_logger(__name__) class TestRunningNodesStaticSharding(StepsSharding): @pytest.mark.parametrize("pubsub_topic", PUBSUB_TOPICS_DIFFERENT_CLUSTERS) def test_single_pubsub_topic(self, pubsub_topic): - self.setup_main_relay_nodes(pubsub_topic=pubsub_topic) + self.setup_main_relay_nodes(pubsub_topic=pubsub_topic, shard=["0", "1", "999"]) self.subscribe_main_relay_nodes(pubsub_topics=[pubsub_topic]) self.check_published_message_reaches_relay_peer(pubsub_topic=pubsub_topic) @@ -20,17 +20,6 @@ class TestRunningNodesStaticSharding(StepsSharding): for pubsub_topic in PUBSUB_TOPICS_SAME_CLUSTER: self.check_published_message_reaches_relay_peer(pubsub_topic=pubsub_topic) - def test_2_nodes_same_cluster_different_shards(self): - self.setup_first_relay_node_with_filter(pubsub_topic=self.test_pubsub_topic) - self.setup_second_relay_node(pubsub_topic="/waku/2/rs/2/1") - self.subscribe_first_relay_node(pubsub_topics=[self.test_pubsub_topic]) - self.subscribe_second_relay_node(pubsub_topics=["/waku/2/rs/2/1"]) - try: - self.check_published_message_reaches_relay_peer(pubsub_topic=self.test_pubsub_topic) - raise AssertionError("Publish on different shard worked!!!") - except Exception as ex: - assert "Not Found" in str(ex) - def test_2_nodes_different_cluster_same_shard(self): self.setup_first_relay_node_with_filter(pubsub_topic=self.test_pubsub_topic) self.setup_second_relay_node(pubsub_topic="/waku/2/rs/4/0")