From 548b4f79d2a1ac9ba338bc2847d0708eb50270a1 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 12 Apr 2024 13:13:01 +0800 Subject: [PATCH 001/139] fix: add get_multiaddr_with_id step - temporarily use local docker images --- src/env_vars.py | 4 ++-- src/steps/relay.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/env_vars.py b/src/env_vars.py index a588185616..6693029fde 100644 --- a/src/env_vars.py +++ b/src/env_vars.py @@ -14,8 +14,8 @@ def get_env_var(var_name, default=None): # Configuration constants. Need to be upercase to appear in reports -DEFAULT_NWAKU = "harbor.status.im/wakuorg/nwaku:latest" -DEFAULT_GOWAKU = "harbor.status.im/wakuorg/go-waku:latest" +DEFAULT_NWAKU = "wakuorg/nwaku:latest" +DEFAULT_GOWAKU = "wakuorg/go-waku:latest" NODE_1 = get_env_var("NODE_1", DEFAULT_GOWAKU) NODE_2 = get_env_var("NODE_2", DEFAULT_NWAKU) ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_GOWAKU},{DEFAULT_NWAKU}") diff --git a/src/steps/relay.py b/src/steps/relay.py index 79a79f3408..97dcd0d927 100644 --- a/src/steps/relay.py +++ b/src/steps/relay.py @@ -47,7 +47,7 @@ def setup_main_relay_nodes(self, request): @pytest.fixture(scope="function") def register_main_rln_relay_nodes(self, request): - logger.debug(f"Registering RLN credentials: {inspect.currentframe().f_code.co_name}") + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") self.node1.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") @@ -60,6 +60,7 @@ def setup_main_rln_relay_nodes(self, request): self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1") self.enr_uri = self.node1.get_enr_uri() + self.multiaddr_with_id = self.node1.get_multiaddr_with_id() self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") self.node2.start( relay="true", discv5_bootstrap_node=self.enr_uri, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2", rln_relay_membership_index="1" From ef05d290f63e2af003597bbd17ce2a31440988da Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 15 Apr 2024 15:01:18 +0800 Subject: [PATCH 002/139] fix: discard containers used for RLN registration --- src/steps/relay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/steps/relay.py b/src/steps/relay.py index 97dcd0d927..59e5db8e2d 100644 --- a/src/steps/relay.py +++ b/src/steps/relay.py @@ -52,7 +52,6 @@ def register_main_rln_relay_nodes(self, request): self.node1.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") self.node2.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") - self.main_nodes.extend([self.node1, self.node2]) @pytest.fixture(scope="function") def setup_main_rln_relay_nodes(self, request): From 5ee97c6610e7155d5eadaa7aba4ecb706ecb5d65 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 15 Apr 2024 15:32:48 +0800 Subject: [PATCH 003/139] fix: switch to use cluster ID 1 for RLN --- src/test_data.py | 2 ++ tests/relay/test_rln.py | 28 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/test_data.py b/src/test_data.py index 3cbb7da193..bf52edd269 100644 --- a/src/test_data.py +++ b/src/test_data.py @@ -148,3 +148,5 @@ {"description": "ISO 8601 timestamp", "value": "2023-12-26T10:58:51", "valid_for": []}, {"description": "Missing", "value": None, "valid_for": ["gowaku"]}, ] + +PUBSUB_TOPICS_RLN = ["/waku/2/rs/1/0"] diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index bab598adff..120d7dfb9b 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -2,23 +2,27 @@ import pytest from src.env_vars import RLN_CREDENTIALS +from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger from src.steps.relay import StepsRelay +from src.test_data import SAMPLE_INPUTS, PUBSUB_TOPICS_RLN logger = get_custom_logger(__name__) -@pytest.mark.usefixtures() +@pytest.mark.usefixtures("register_main_rln_relay_nodes", "setup_main_rln_relay_nodes", "subscribe_main_relay_nodes") class TestRelayRLN(StepsRelay): - def test_register_rln(self): - logger.debug("Running register RLN test for main relay nodes") - key_stores_found = 0 + test_pubsub_topic = PUBSUB_TOPICS_RLN[0] - if RLN_CREDENTIALS is None: - pytest.skip("RLN_CREDENTIALS not set, skipping test") - - for k in range(1, 6): - self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id=f"{k}") - self.check_rln_registration(k) - key_stores_found += 1 - assert key_stores_found == 5, f"Invalid number of RLN keystores found, expected 5 found {key_stores_found}" + def test_publish_valid_payloads_at_slow_pace(self): + failed_payloads = [] + for payload in SAMPLE_INPUTS: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.check_published_message_reaches_relay_peer(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + delay(1) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" From c4f48e7824807db6e5b0b274c5faa2e48099b9f8 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 15 Apr 2024 19:08:17 +0800 Subject: [PATCH 004/139] test: publish at slow and spam rate --- tests/relay/test_rln.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 120d7dfb9b..7d8b86c6f2 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -14,9 +14,9 @@ class TestRelayRLN(StepsRelay): test_pubsub_topic = PUBSUB_TOPICS_RLN[0] - def test_publish_valid_payloads_at_slow_pace(self): + def test_publish_with_valid_payloads_at_slow_rate(self): failed_payloads = [] - for payload in SAMPLE_INPUTS: + for payload in SAMPLE_INPUTS[:5]: logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -26,3 +26,15 @@ def test_publish_valid_payloads_at_slow_pace(self): failed_payloads.append(payload["description"]) delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + def test_publish_with_valid_payloads_at_spam_rate(self): + for i, payload in enumerate(SAMPLE_INPUTS[:3]): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.check_published_message_reaches_relay_peer(message) + if i > 1: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + assert "RLN validation failed" in str(e) From ea63da230de4a1030ff2656fe05848803d0b9823 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 15 Apr 2024 19:45:26 +0800 Subject: [PATCH 005/139] fix: shorten test data set --- tests/relay/test_rln.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 7d8b86c6f2..e0e71c5b8d 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -28,13 +28,12 @@ def test_publish_with_valid_payloads_at_slow_rate(self): assert not failed_payloads, f"Payloads failed: {failed_payloads}" def test_publish_with_valid_payloads_at_spam_rate(self): - for i, payload in enumerate(SAMPLE_INPUTS[:3]): + for i, payload in enumerate(SAMPLE_INPUTS[:2]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: self.check_published_message_reaches_relay_peer(message) - if i > 1: + if i > 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") except Exception as e: - logger.error(f'Payload {payload["description"]} failed: {str(e)}') assert "RLN validation failed" in str(e) From 896bf257bc8ea2ab58eda60be5375bf9342245b6 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 16 Apr 2024 14:47:50 +0800 Subject: [PATCH 006/139] fix: move RLN related code into separate class --- src/steps/relay.py | 46 ++----------------------------- src/steps/rln.py | 60 +++++++++++++++++++++++++++++++++++++++++ tests/relay/test_rln.py | 9 +++---- 3 files changed, 65 insertions(+), 50 deletions(-) create mode 100644 src/steps/rln.py diff --git a/src/steps/relay.py b/src/steps/relay.py index 59e5db8e2d..32a0fc2ea3 100644 --- a/src/steps/relay.py +++ b/src/steps/relay.py @@ -1,20 +1,17 @@ import inspect -import os from src.libs.custom_logger import get_custom_logger from time import time import pytest import allure -from src.libs.common import to_base64, delay, gen_step_id +from src.libs.common import to_base64, delay from src.node.waku_message import WakuMessage from src.env_vars import ( NODE_1, NODE_2, ADDITIONAL_NODES, NODEKEY, - DEFAULT_NWAKU, - RLN_CREDENTIALS, ) -from src.node.waku_node import WakuNode, rln_credential_store_ready +from src.node.waku_node import WakuNode from tenacity import retry, stop_after_delay, wait_fixed from src.test_data import VALID_PUBSUB_TOPICS @@ -45,29 +42,6 @@ def setup_main_relay_nodes(self, request): self.node2.add_peers([self.multiaddr_with_id]) self.main_nodes.extend([self.node1, self.node2]) - @pytest.fixture(scope="function") - def register_main_rln_relay_nodes(self, request): - logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") - self.node1.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") - self.node2.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") - - @pytest.fixture(scope="function") - def setup_main_rln_relay_nodes(self, request): - logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") - self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1") - self.enr_uri = self.node1.get_enr_uri() - self.multiaddr_with_id = self.node1.get_multiaddr_with_id() - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") - self.node2.start( - relay="true", discv5_bootstrap_node=self.enr_uri, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2", rln_relay_membership_index="1" - ) - if self.node2.is_nwaku(): - self.node2.add_peers([self.multiaddr_with_id]) - self.main_nodes.extend([self.node1, self.node2]) - @pytest.fixture(scope="function") def setup_optional_relay_nodes(self, request): logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") @@ -164,19 +138,3 @@ def create_message(self, **kwargs): def subscribe_and_publish_with_retry(self, node_list, pubsub_topic_list): self.ensure_relay_subscriptions_on_nodes(node_list, pubsub_topic_list) self.check_published_message_reaches_relay_peer() - - @allure.step - def register_rln_single_node(self, **kwargs): - logger.debug("Registering RLN credentials for single node") - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{gen_step_id()}") - self.node1.register_rln(rln_creds_source=kwargs["rln_creds_source"], rln_creds_id=kwargs["rln_creds_id"]) - - @allure.step - def check_rln_registration(self, key_id): - current_working_directory = os.getcwd() - creds_file_path = f"{current_working_directory}/keystore_{key_id}/keystore.json" - try: - rln_credential_store_ready(creds_file_path) - except Exception as ex: - logger.error(f"Credentials at {creds_file_path} not available: {ex}") - raise diff --git a/src/steps/rln.py b/src/steps/rln.py new file mode 100644 index 0000000000..9b971d1e70 --- /dev/null +++ b/src/steps/rln.py @@ -0,0 +1,60 @@ +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY +from src.libs.common import gen_step_id +from src.libs.custom_logger import get_custom_logger +import os +import inspect +import pytest +import allure +from src.node.waku_node import WakuNode, rln_credential_store_ready +from tenacity import retry, stop_after_delay, wait_fixed +from src.test_data import PUBSUB_TOPICS_RLN + +logger = get_custom_logger(__name__) + + +class StepsRLN: + test_pubsub_topic = PUBSUB_TOPICS_RLN[0] + test_content_topic = "/test/1/waku-rln-relay/proto" + test_payload = "RLN relay works!!" + + main_nodes = [] + optional_nodes = [] + + @pytest.fixture(scope="function") + def register_main_rln_relay_nodes(self, request): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") + self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") + self.node1.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") + self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") + self.node2.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") + + @pytest.fixture(scope="function") + def setup_main_rln_relay_nodes(self, request): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") + self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") + self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1") + self.enr_uri = self.node1.get_enr_uri() + self.multiaddr_with_id = self.node1.get_multiaddr_with_id() + self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") + self.node2.start( + relay="true", discv5_bootstrap_node=self.enr_uri, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2", rln_relay_membership_index="1" + ) + if self.node2.is_nwaku(): + self.node2.add_peers([self.multiaddr_with_id]) + self.main_nodes.extend([self.node1, self.node2]) + + @allure.step + def register_rln_single_node(self, **kwargs): + logger.debug("Registering RLN credentials for single node") + self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{gen_step_id()}") + self.node1.register_rln(rln_creds_source=kwargs["rln_creds_source"], rln_creds_id=kwargs["rln_creds_id"]) + + @allure.step + def check_rln_registration(self, key_id): + current_working_directory = os.getcwd() + creds_file_path = f"{current_working_directory}/keystore_{key_id}/keystore.json" + try: + rln_credential_store_ready(creds_file_path) + except Exception as ex: + logger.error(f"Credentials at {creds_file_path} not available: {ex}") + raise diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index e0e71c5b8d..d183f96047 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -1,19 +1,16 @@ -import os import pytest -from src.env_vars import RLN_CREDENTIALS from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger from src.steps.relay import StepsRelay -from src.test_data import SAMPLE_INPUTS, PUBSUB_TOPICS_RLN +from src.steps.rln import StepsRLN +from src.test_data import SAMPLE_INPUTS logger = get_custom_logger(__name__) @pytest.mark.usefixtures("register_main_rln_relay_nodes", "setup_main_rln_relay_nodes", "subscribe_main_relay_nodes") -class TestRelayRLN(StepsRelay): - test_pubsub_topic = PUBSUB_TOPICS_RLN[0] - +class TestRelayRLN(StepsRLN, StepsRelay): def test_publish_with_valid_payloads_at_slow_rate(self): failed_payloads = [] for payload in SAMPLE_INPUTS[:5]: From ab06596fc4d6733411e54860491a923b9b79deeb Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 17 Apr 2024 22:20:39 +0800 Subject: [PATCH 007/139] fix: use send only publish function - add spam and alternate rate tests --- src/steps/rln.py | 22 +++++++++++++++++++--- tests/relay/test_rln.py | 33 +++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 9b971d1e70..27e2b59496 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -1,12 +1,12 @@ from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY -from src.libs.common import gen_step_id +from src.libs.common import gen_step_id, to_base64 from src.libs.custom_logger import get_custom_logger import os import inspect import pytest import allure +from time import time from src.node.waku_node import WakuNode, rln_credential_store_ready -from tenacity import retry, stop_after_delay, wait_fixed from src.test_data import PUBSUB_TOPICS_RLN logger = get_custom_logger(__name__) @@ -16,7 +16,7 @@ class StepsRLN: test_pubsub_topic = PUBSUB_TOPICS_RLN[0] test_content_topic = "/test/1/waku-rln-relay/proto" test_payload = "RLN relay works!!" - + epoch_time = 1 # seconds main_nodes = [] optional_nodes = [] @@ -58,3 +58,19 @@ def check_rln_registration(self, key_id): except Exception as ex: logger.error(f"Credentials at {creds_file_path} not available: {ex}") raise + + @allure.step + def create_message(self, **kwargs): + message = {"payload": to_base64(self.test_payload), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)} + message.update(kwargs) + return message + + def publish_message(self, message=None, pubsub_topic=None, sender=None): + if message is None: + message = self.create_message() + if pubsub_topic is None: + pubsub_topic = self.test_pubsub_topic + if not sender: + sender = self.node1 + + sender.send_relay_message(message, pubsub_topic) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index d183f96047..9d02cd6ad1 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -1,3 +1,6 @@ +import math +from time import time + import pytest from src.libs.common import delay, to_base64 @@ -17,7 +20,7 @@ def test_publish_with_valid_payloads_at_slow_rate(self): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - self.check_published_message_reaches_relay_peer(message) + self.publish_message(message) except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) @@ -25,12 +28,34 @@ def test_publish_with_valid_payloads_at_slow_rate(self): assert not failed_payloads, f"Payloads failed: {failed_payloads}" def test_publish_with_valid_payloads_at_spam_rate(self): - for i, payload in enumerate(SAMPLE_INPUTS[:2]): + previous = int(time()) + for i, payload in enumerate(SAMPLE_INPUTS[:4]): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + now = int(time()) + self.publish_message(message) + if i > 0 and (now - previous) == 0: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now + except Exception as e: + assert "RLN validation failed" in str(e) + + def test_publish_with_valid_payloads_at_alternate_rate(self): + previous = math.trunc(time()) + for i, payload in enumerate(SAMPLE_INPUTS): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - self.check_published_message_reaches_relay_peer(message) - if i > 0: + if (i + 1) % 2 == 1: # every odd sample should be sent slowly + delay(1) + now = math.trunc(time()) + logger.debug(f"Message sent at timestamp {now}") + self.publish_message(message) + if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now except Exception as e: assert "RLN validation failed" in str(e) From 742a00b005c7fc6ea871509242926fa6c2697fcb Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 17 Apr 2024 22:58:58 +0800 Subject: [PATCH 008/139] fix: use math.trunc instead of rounding --- tests/relay/test_rln.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 9d02cd6ad1..71ab468a2d 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -24,16 +24,16 @@ def test_publish_with_valid_payloads_at_slow_rate(self): except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) - delay(1) + delay(self.epoch_time) assert not failed_payloads, f"Payloads failed: {failed_payloads}" def test_publish_with_valid_payloads_at_spam_rate(self): - previous = int(time()) + previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS[:4]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - now = int(time()) + now = math.trunc(time()) self.publish_message(message) if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") @@ -42,16 +42,16 @@ def test_publish_with_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - def test_publish_with_valid_payloads_at_alternate_rate(self): + def test_publish_with_valid_payloads_at_variable_rate(self): previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: if (i + 1) % 2 == 1: # every odd sample should be sent slowly - delay(1) + delay(self.epoch_time) now = math.trunc(time()) - logger.debug(f"Message sent at timestamp {now}") + # logger.debug(f"Message sent at timestamp {now}") self.publish_message(message) if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") From 14b113a7ac36a0960e66c554aca39d762e3e19e6 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 17 Apr 2024 23:23:05 +0800 Subject: [PATCH 009/139] fix: first message without delay --- tests/relay/test_rln.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 71ab468a2d..08ebd1d05f 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -48,10 +48,10 @@ def test_publish_with_valid_payloads_at_variable_rate(self): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - if (i + 1) % 2 == 1: # every odd sample should be sent slowly + if i % 2 == 1: # every sample with odd index is sent slowly delay(self.epoch_time) now = math.trunc(time()) - # logger.debug(f"Message sent at timestamp {now}") + logger.debug(f"Message sent at timestamp {now}") self.publish_message(message) if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") From 12e287cc832a66e05c72f1afbc4b8e2031aff0e5 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 17 Apr 2024 23:29:59 +0800 Subject: [PATCH 010/139] fix: add one more second to messages with delay --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 08ebd1d05f..e41a56b806 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -49,7 +49,7 @@ def test_publish_with_valid_payloads_at_variable_rate(self): message = self.create_message(payload=to_base64(payload["value"])) try: if i % 2 == 1: # every sample with odd index is sent slowly - delay(self.epoch_time) + delay(self.epoch_time + 1) now = math.trunc(time()) logger.debug(f"Message sent at timestamp {now}") self.publish_message(message) From 84fe165bb403a3224040a2a0a89b1b12d34f7b9e Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 18 Apr 2024 16:10:44 +0800 Subject: [PATCH 011/139] fix: add methods to setup non default RLN nodes --- src/steps/rln.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 27e2b59496..d757404a11 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -1,4 +1,4 @@ -from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY, NODE_1, NODE_2 from src.libs.common import gen_step_id, to_base64 from src.libs.custom_logger import get_custom_logger import os @@ -16,7 +16,7 @@ class StepsRLN: test_pubsub_topic = PUBSUB_TOPICS_RLN[0] test_content_topic = "/test/1/waku-rln-relay/proto" test_payload = "RLN relay works!!" - epoch_time = 1 # seconds + main_nodes = [] optional_nodes = [] @@ -43,6 +43,29 @@ def setup_main_rln_relay_nodes(self, request): self.node2.add_peers([self.multiaddr_with_id]) self.main_nodes.extend([self.node1, self.node2]) + @allure.step + def setup_first_non_default_rln_relay_node(self, **kwargs): + self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") + self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1", **kwargs) + self.enr_uri = self.node1.get_enr_uri() + self.multiaddr_with_id = self.node1.get_multiaddr_with_id() + self.main_nodes.extend([self.node1]) + + @allure.step + def setup_second_non_default_rln_relay_node(self, **kwargs): + self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") + self.node2.start( + relay="true", + discv5_bootstrap_node=self.enr_uri, + rln_creds_source=RLN_CREDENTIALS, + rln_creds_id="2", + rln_relay_membership_index="1", + **kwargs, + ) + if self.node2.is_nwaku(): + self.node2.add_peers([self.multiaddr_with_id]) + self.main_nodes.extend([self.node2]) + @allure.step def register_rln_single_node(self, **kwargs): logger.debug("Registering RLN credentials for single node") @@ -65,6 +88,7 @@ def create_message(self, **kwargs): message.update(kwargs) return message + @allure.step def publish_message(self, message=None, pubsub_topic=None, sender=None): if message is None: message = self.create_message() From aa8177cd009b020ee2697eccee79d199dfb8a11e Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 18 Apr 2024 19:21:50 +0800 Subject: [PATCH 012/139] fix: rewrite tests using steps rather than fixtures - prepare for non default settings for RLN --- src/steps/rln.py | 14 ++++++++++++-- tests/relay/test_rln.py | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index d757404a11..d201748900 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -44,7 +44,7 @@ def setup_main_rln_relay_nodes(self, request): self.main_nodes.extend([self.node1, self.node2]) @allure.step - def setup_first_non_default_rln_relay_node(self, **kwargs): + def setup_first_rln_relay_node(self, **kwargs): self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1", **kwargs) self.enr_uri = self.node1.get_enr_uri() @@ -52,7 +52,7 @@ def setup_first_non_default_rln_relay_node(self, **kwargs): self.main_nodes.extend([self.node1]) @allure.step - def setup_second_non_default_rln_relay_node(self, **kwargs): + def setup_second_rln_relay_node(self, **kwargs): self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") self.node2.start( relay="true", @@ -98,3 +98,13 @@ def publish_message(self, message=None, pubsub_topic=None, sender=None): sender = self.node1 sender.send_relay_message(message, pubsub_topic) + + @allure.step + def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): + for node in node_list: + node.set_relay_subscriptions(pubsub_topic_list) + + @allure.step + def subscribe_main_relay_nodes(self): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") + self.ensure_relay_subscriptions_on_nodes(self.main_nodes, [self.test_pubsub_topic]) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index e41a56b806..d48fcd6942 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -12,9 +12,12 @@ logger = get_custom_logger(__name__) -@pytest.mark.usefixtures("register_main_rln_relay_nodes", "setup_main_rln_relay_nodes", "subscribe_main_relay_nodes") +@pytest.mark.usefixtures("register_main_rln_relay_nodes") class TestRelayRLN(StepsRLN, StepsRelay): def test_publish_with_valid_payloads_at_slow_rate(self): + self.setup_first_rln_relay_node() + self.setup_second_rln_relay_node() + self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS[:5]: logger.debug(f'Running test with payload {payload["description"]}') @@ -24,10 +27,13 @@ def test_publish_with_valid_payloads_at_slow_rate(self): except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) - delay(self.epoch_time) + delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" def test_publish_with_valid_payloads_at_spam_rate(self): + self.setup_first_rln_relay_node() + self.setup_second_rln_relay_node() + self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS[:4]): logger.debug(f'Running test with payload {payload["description"]}') @@ -43,13 +49,16 @@ def test_publish_with_valid_payloads_at_spam_rate(self): assert "RLN validation failed" in str(e) def test_publish_with_valid_payloads_at_variable_rate(self): + self.setup_first_rln_relay_node() + self.setup_second_rln_relay_node() + self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: if i % 2 == 1: # every sample with odd index is sent slowly - delay(self.epoch_time + 1) + delay(1 + 1) now = math.trunc(time()) logger.debug(f"Message sent at timestamp {now}") self.publish_message(message) From 309cfbc6f2b530e56e32c6a59c6ca8b7f3127bd5 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 18 Apr 2024 19:35:02 +0800 Subject: [PATCH 013/139] test: random epoch with valid_payloads_at_slow_rate --- tests/relay/test_rln.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index d48fcd6942..7467772af0 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -1,4 +1,5 @@ import math +import random from time import time import pytest @@ -68,3 +69,20 @@ def test_publish_with_valid_payloads_at_variable_rate(self): previous = now except Exception as e: assert "RLN validation failed" in str(e) + + def test_publish_with_valid_payloads_at_slow_rate_rand_epoch(self): + epoch_sec = random.randint(2, 5) + self.setup_first_rln_relay_node(rln_relay_epoch_sec=epoch_sec) + self.setup_second_rln_relay_node(rln_relay_epoch_sec=epoch_sec) + self.subscribe_main_relay_nodes() + failed_payloads = [] + for payload in SAMPLE_INPUTS[:5]: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.publish_message(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + delay(epoch_sec) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" From b1316a90246e9656bcabd3f59c039861e3ccfca7 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 18 Apr 2024 20:18:18 +0800 Subject: [PATCH 014/139] test: random user message limit with valid payloads --- tests/relay/test_rln.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 7467772af0..7334b65544 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -86,3 +86,19 @@ def test_publish_with_valid_payloads_at_slow_rate_rand_epoch(self): failed_payloads.append(payload["description"]) delay(epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + def test_publish_with_valid_payloads_random_user_message_limit(self): + user_message_limit = random.randint(2, 4) + self.setup_first_rln_relay_node(rln_relay_user_message_limit=user_message_limit) + self.setup_second_rln_relay_node(rln_relay_user_message_limit=user_message_limit) + self.subscribe_main_relay_nodes() + failed_payloads = [] + for payload in SAMPLE_INPUTS[:user_message_limit]: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.publish_message(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" From 946d8936afa765e8d812b1785d3ca8e8abca880b Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 19 Apr 2024 13:23:37 +0800 Subject: [PATCH 015/139] fix: skip test "random user message limit with valid payloads" --- tests/relay/test_rln.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 7334b65544..68262ef272 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -87,6 +87,7 @@ def test_publish_with_valid_payloads_at_slow_rate_rand_epoch(self): delay(epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.skip(reason="waiting for RLN v2 implementation") def test_publish_with_valid_payloads_random_user_message_limit(self): user_message_limit = random.randint(2, 4) self.setup_first_rln_relay_node(rln_relay_user_message_limit=user_message_limit) From a247e39abc23f59a3282c273a83c047282114401 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 19 Apr 2024 13:29:25 +0800 Subject: [PATCH 016/139] fix: mark flaky "at variable_rate with valid payloads" --- tests/relay/test_rln.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 68262ef272..1ecaa402ed 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -49,6 +49,7 @@ def test_publish_with_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.skip(reason="flaky because of problems with time measurement") def test_publish_with_valid_payloads_at_variable_rate(self): self.setup_first_rln_relay_node() self.setup_second_rln_relay_node() From 54cc4ff4aa491f21a1f245aeb233b35ecfea09b8 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 19 Apr 2024 15:54:46 +0800 Subject: [PATCH 017/139] fix: rename tests for easier debugging --- tests/relay/test_rln.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 1ecaa402ed..653300f3e0 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -71,7 +71,7 @@ def test_publish_with_valid_payloads_at_variable_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - def test_publish_with_valid_payloads_at_slow_rate_rand_epoch(self): + def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): epoch_sec = random.randint(2, 5) self.setup_first_rln_relay_node(rln_relay_epoch_sec=epoch_sec) self.setup_second_rln_relay_node(rln_relay_epoch_sec=epoch_sec) @@ -104,3 +104,19 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): + self.setup_first_rln_relay_node(rln_relay_dynamic="true") + self.setup_second_rln_relay_node(rln_relay_dynamic="true") + self.subscribe_main_relay_nodes() + failed_payloads = [] + for payload in SAMPLE_INPUTS[:5]: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.publish_message(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + delay(1) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" From a539dcc2819c45487d84859e94c53a2ceccebda3 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 22 Apr 2024 15:45:09 +0800 Subject: [PATCH 018/139] fix: mark valid_payloads_dynamic_at_slow_rate to skip --- src/node/waku_node.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node/waku_node.py b/src/node/waku_node.py index a4ba7d1aad..5d88ecbf65 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -114,6 +114,8 @@ def start(self, **kwargs): else: logger.info(f"RLN credentials not set or credential store not available, starting without RLN") + logger.debug(f"Using volumes {self._volumes}") + self._container = self._docker_manager.start_container( self._docker_manager.image, self._ports, default_args, self._log_path, self._ext_ip, self._volumes ) From 2c81b2dfa3bdef02e51feadee16efb03c7cdbd09 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 22 Apr 2024 15:46:09 +0800 Subject: [PATCH 019/139] fix: forgot to add actual file --- tests/relay/test_rln.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 653300f3e0..39a7a41d7c 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -105,6 +105,7 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.skip(reason="pending on https://github.com/waku-org/nwaku/issues/2606") def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): self.setup_first_rln_relay_node(rln_relay_dynamic="true") self.setup_second_rln_relay_node(rln_relay_dynamic="true") From efeed3d180086ddc2a33a1bbd35f3714afac2875 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 13:57:47 +0800 Subject: [PATCH 020/139] test: valid payloads dynamic(on chain) at spam rate - extend timeout for ensure_ready() to 600s - add ensure_healthy() for future use - add text content based rest call - remove NODE1, NODE2 imports --- src/node/api_clients/rest.py | 9 +++++++++ src/node/waku_node.py | 10 +++++++++- src/steps/rln.py | 2 +- tests/relay/test_rln.py | 21 ++++++++++++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/node/api_clients/rest.py b/src/node/api_clients/rest.py index bfb6bea0a4..daaedd0c64 100644 --- a/src/node/api_clients/rest.py +++ b/src/node/api_clients/rest.py @@ -15,10 +15,19 @@ def rest_call(self, method, endpoint, payload=None): headers = {"Content-Type": "application/json"} return self.make_request(method, url, headers=headers, data=payload) + def rest_call_text(self, method, endpoint, payload=None): + url = f"http://127.0.0.1:{self._rest_port}/{endpoint}" + headers = {"accept": "text/plain"} + return self.make_request(method, url, headers=headers, data=payload) + def info(self): info_response = self.rest_call("get", "debug/v1/info") return info_response.json() + def health(self): + health_response = self.rest_call_text("get", "health") + return health_response.text() + def get_peers(self): get_peers_response = self.rest_call("get", "admin/v1/peers") return get_peers_response.json() diff --git a/src/node/waku_node.py b/src/node/waku_node.py index 5d88ecbf65..376cfd228b 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -187,11 +187,16 @@ def unpause(self): logger.debug(f"Unpause container with id {self._container.short_id}") self._container.unpause() - @retry(stop=stop_after_delay(10), wait=wait_fixed(0.1), reraise=True) + @retry(stop=stop_after_delay(600), wait=wait_fixed(1), reraise=True) def ensure_ready(self): self.info_response = self.info() logger.info("REST service is ready !!") + @retry(stop=stop_after_delay(600), wait=wait_fixed(1), reraise=True) + def ensure_healthy(self): + self.health_response = self.health() + logger.info("Node is healthy !!") + def get_enr_uri(self): try: return self.info_response["enrUri"] @@ -211,6 +216,9 @@ def get_multiaddr_with_id(self): def info(self): return self._api.info() + def health(self): + return self._api.health() + def get_peers(self): return self._api.get_peers() diff --git a/src/steps/rln.py b/src/steps/rln.py index d201748900..c48ba704a7 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -1,4 +1,4 @@ -from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY, NODE_1, NODE_2 +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY from src.libs.common import gen_step_id, to_base64 from src.libs.custom_logger import get_custom_logger import os diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 39a7a41d7c..40f3218d2a 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -105,7 +105,7 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="pending on https://github.com/waku-org/nwaku/issues/2606") + @pytest.mark.timeout(600) def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): self.setup_first_rln_relay_node(rln_relay_dynamic="true") self.setup_second_rln_relay_node(rln_relay_dynamic="true") @@ -121,3 +121,22 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): failed_payloads.append(payload["description"]) delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + @pytest.mark.timeout(600) + def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): + self.setup_first_rln_relay_node(rln_relay_dynamic="true") + self.setup_second_rln_relay_node(rln_relay_dynamic="true") + self.subscribe_main_relay_nodes() + previous = math.trunc(time()) + for i, payload in enumerate(SAMPLE_INPUTS[:4]): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + now = math.trunc(time()) + self.publish_message(message) + if i > 0 and (now - previous) == 0: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now + except Exception as e: + assert "RLN validation failed" in str(e) From 472aa81afbbf146b3b606e328a1eb45411923d7d Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 15:41:53 +0800 Subject: [PATCH 021/139] fix: revert env_vars to source images from Harbor --- src/env_vars.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/env_vars.py b/src/env_vars.py index 6693029fde..a588185616 100644 --- a/src/env_vars.py +++ b/src/env_vars.py @@ -14,8 +14,8 @@ def get_env_var(var_name, default=None): # Configuration constants. Need to be upercase to appear in reports -DEFAULT_NWAKU = "wakuorg/nwaku:latest" -DEFAULT_GOWAKU = "wakuorg/go-waku:latest" +DEFAULT_NWAKU = "harbor.status.im/wakuorg/nwaku:latest" +DEFAULT_GOWAKU = "harbor.status.im/wakuorg/go-waku:latest" NODE_1 = get_env_var("NODE_1", DEFAULT_GOWAKU) NODE_2 = get_env_var("NODE_2", DEFAULT_NWAKU) ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_GOWAKU},{DEFAULT_NWAKU}") From b7514660c5478691e26198bb919b81b1a89a4bce Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 17:19:23 +0800 Subject: [PATCH 022/139] fix: reuse setup first and second rln relay node for setup_main_rln_relay_nodes --- src/steps/rln.py | 18 ++++-------------- tests/relay/test_rln.py | 21 +++++++-------------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index c48ba704a7..ffce0def42 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -28,20 +28,10 @@ def register_main_rln_relay_nodes(self, request): self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") self.node2.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") - @pytest.fixture(scope="function") - def setup_main_rln_relay_nodes(self, request): - logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") - self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1") - self.enr_uri = self.node1.get_enr_uri() - self.multiaddr_with_id = self.node1.get_multiaddr_with_id() - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") - self.node2.start( - relay="true", discv5_bootstrap_node=self.enr_uri, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2", rln_relay_membership_index="1" - ) - if self.node2.is_nwaku(): - self.node2.add_peers([self.multiaddr_with_id]) - self.main_nodes.extend([self.node1, self.node2]) + @allure.step + def setup_main_rln_relay_nodes(self, **kwargs): + self.setup_first_rln_relay_node(**kwargs) + self.setup_second_rln_relay_node(**kwargs) @allure.step def setup_first_rln_relay_node(self, **kwargs): diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 40f3218d2a..a5bc593455 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -16,8 +16,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") class TestRelayRLN(StepsRLN, StepsRelay): def test_publish_with_valid_payloads_at_slow_rate(self): - self.setup_first_rln_relay_node() - self.setup_second_rln_relay_node() + self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS[:5]: @@ -32,8 +31,7 @@ def test_publish_with_valid_payloads_at_slow_rate(self): assert not failed_payloads, f"Payloads failed: {failed_payloads}" def test_publish_with_valid_payloads_at_spam_rate(self): - self.setup_first_rln_relay_node() - self.setup_second_rln_relay_node() + self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS[:4]): @@ -51,8 +49,7 @@ def test_publish_with_valid_payloads_at_spam_rate(self): @pytest.mark.skip(reason="flaky because of problems with time measurement") def test_publish_with_valid_payloads_at_variable_rate(self): - self.setup_first_rln_relay_node() - self.setup_second_rln_relay_node() + self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS): @@ -73,8 +70,7 @@ def test_publish_with_valid_payloads_at_variable_rate(self): def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): epoch_sec = random.randint(2, 5) - self.setup_first_rln_relay_node(rln_relay_epoch_sec=epoch_sec) - self.setup_second_rln_relay_node(rln_relay_epoch_sec=epoch_sec) + self.setup_main_rln_relay_nodes(rln_relay_epoch_sec=epoch_sec) self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS[:5]: @@ -91,8 +87,7 @@ def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): @pytest.mark.skip(reason="waiting for RLN v2 implementation") def test_publish_with_valid_payloads_random_user_message_limit(self): user_message_limit = random.randint(2, 4) - self.setup_first_rln_relay_node(rln_relay_user_message_limit=user_message_limit) - self.setup_second_rln_relay_node(rln_relay_user_message_limit=user_message_limit) + self.setup_main_rln_relay_nodes(rln_relay_user_message_limit=user_message_limit) self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS[:user_message_limit]: @@ -107,8 +102,7 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): @pytest.mark.timeout(600) def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): - self.setup_first_rln_relay_node(rln_relay_dynamic="true") - self.setup_second_rln_relay_node(rln_relay_dynamic="true") + self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS[:5]: @@ -124,8 +118,7 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): @pytest.mark.timeout(600) def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): - self.setup_first_rln_relay_node(rln_relay_dynamic="true") - self.setup_second_rln_relay_node(rln_relay_dynamic="true") + self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS[:4]): From 84fb188779980ef8126b1c49b218f440c19f6938 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 19:24:51 +0800 Subject: [PATCH 023/139] fix: reuse register_rln_single_node for register_main_rln_relay_nodes --- src/steps/rln.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index ffce0def42..34a6b2c09a 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -23,10 +23,8 @@ class StepsRLN: @pytest.fixture(scope="function") def register_main_rln_relay_nodes(self, request): logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") - self.node1.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") - self.node2.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") + self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") + self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") @allure.step def setup_main_rln_relay_nodes(self, **kwargs): From 6b3c8c3cdd09c51b3f5e5537f60df3769601f5f6 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 19:41:38 +0800 Subject: [PATCH 024/139] fix: start using src.steps.common - removed RLN test class inheritance from StepsRelay --- src/steps/rln.py | 18 ++++++------------ tests/relay/test_rln.py | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 34a6b2c09a..1d250e6607 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -1,18 +1,18 @@ -from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY -from src.libs.common import gen_step_id, to_base64 -from src.libs.custom_logger import get_custom_logger import os import inspect import pytest import allure -from time import time -from src.node.waku_node import WakuNode, rln_credential_store_ready +from src.steps.common import StepsCommon from src.test_data import PUBSUB_TOPICS_RLN +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY +from src.libs.common import gen_step_id +from src.libs.custom_logger import get_custom_logger +from src.node.waku_node import WakuNode, rln_credential_store_ready logger = get_custom_logger(__name__) -class StepsRLN: +class StepsRLN(StepsCommon): test_pubsub_topic = PUBSUB_TOPICS_RLN[0] test_content_topic = "/test/1/waku-rln-relay/proto" test_payload = "RLN relay works!!" @@ -70,12 +70,6 @@ def check_rln_registration(self, key_id): logger.error(f"Credentials at {creds_file_path} not available: {ex}") raise - @allure.step - def create_message(self, **kwargs): - message = {"payload": to_base64(self.test_payload), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)} - message.update(kwargs) - return message - @allure.step def publish_message(self, message=None, pubsub_topic=None, sender=None): if message is None: diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index a5bc593455..2938732e9d 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -14,7 +14,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") -class TestRelayRLN(StepsRLN, StepsRelay): +class TestRelayRLN(StepsRLN): def test_publish_with_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() From 31afbcf66bd1cc2cd0524873c8a2ef89304ff058 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 19:49:30 +0800 Subject: [PATCH 025/139] fix: test using whole data set at test payloads_at_slow_rate --- tests/relay/test_rln.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 2938732e9d..399ee5bb7f 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -1,12 +1,9 @@ import math import random from time import time - import pytest - from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger -from src.steps.relay import StepsRelay from src.steps.rln import StepsRLN from src.test_data import SAMPLE_INPUTS @@ -19,7 +16,7 @@ def test_publish_with_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() failed_payloads = [] - for payload in SAMPLE_INPUTS[:5]: + for payload in SAMPLE_INPUTS: logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: From 8b696857e4e6db2a3f6737bc7daa557394b27f00 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 24 Apr 2024 10:47:58 +0800 Subject: [PATCH 026/139] fix: switch to send msg and check for slow rate tests --- src/steps/rln.py | 26 ++++++++++++++++++++++++-- tests/relay/test_rln.py | 6 +++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 1d250e6607..011fad3a55 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -2,10 +2,12 @@ import inspect import pytest import allure + +from src.node.waku_message import WakuMessage from src.steps.common import StepsCommon from src.test_data import PUBSUB_TOPICS_RLN from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY -from src.libs.common import gen_step_id +from src.libs.common import gen_step_id, delay from src.libs.custom_logger import get_custom_logger from src.node.waku_node import WakuNode, rln_credential_store_ready @@ -81,6 +83,27 @@ def publish_message(self, message=None, pubsub_topic=None, sender=None): sender.send_relay_message(message, pubsub_topic) + @allure.step + def check_published_message_reaches_relay_peer(self, message=None, pubsub_topic=None, message_propagation_delay=0.1, sender=None, peer_list=None): + if message is None: + message = self.create_message() + if pubsub_topic is None: + pubsub_topic = self.test_pubsub_topic + if not sender: + sender = self.node1 + if not peer_list: + peer_list = self.main_nodes + self.optional_nodes + + sender.send_relay_message(message, pubsub_topic) + delay(message_propagation_delay) + for index, peer in enumerate(peer_list): + logger.debug(f"Checking that peer NODE_{index + 1}:{peer.image} can find the published message") + get_messages_response = peer.get_relay_messages(pubsub_topic) + assert get_messages_response, f"Peer NODE_{index + 1}:{peer.image} couldn't find any messages" + assert len(get_messages_response) == 1, f"Expected 1 message but got {len(get_messages_response)}" + waku_message = WakuMessage(get_messages_response) + waku_message.assert_received_message(message) + @allure.step def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): for node in node_list: @@ -88,5 +111,4 @@ def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): @allure.step def subscribe_main_relay_nodes(self): - logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") self.ensure_relay_subscriptions_on_nodes(self.main_nodes, [self.test_pubsub_topic]) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 399ee5bb7f..bf71ddd5b5 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -20,7 +20,7 @@ def test_publish_with_valid_payloads_at_slow_rate(self): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - self.publish_message(message) + self.check_published_message_reaches_relay_peer(message) except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) @@ -74,7 +74,7 @@ def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - self.publish_message(message) + self.check_published_message_reaches_relay_peer(message) except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) @@ -106,7 +106,7 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - self.publish_message(message) + self.check_published_message_reaches_relay_peer(message) except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) From 29cdee264b9f05e85e65718e9d778788a1881f35 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 24 Apr 2024 16:15:15 +0800 Subject: [PATCH 027/139] fix: add comment for skip check at first message --- tests/relay/test_rln.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index bf71ddd5b5..bb51f82e10 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -31,12 +31,13 @@ def test_publish_with_valid_payloads_at_spam_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS[:4]): + for i, payload in enumerate(SAMPLE_INPUTS): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: now = math.trunc(time()) self.publish_message(message) + # Skip for the first message (i > 0) - previous could be too apart from now if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") else: @@ -97,7 +98,7 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.timeout(600) + @pytest.mark.timeout(700) def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() @@ -113,7 +114,7 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.timeout(600) + @pytest.mark.timeout(700) def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() From 5e3df536b57bfed5c3293d363817885f05f2c530 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 24 Apr 2024 16:48:26 +0800 Subject: [PATCH 028/139] fix: refactor payloads_at_variable_rate to use only one payload pattern --- tests/relay/test_rln.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index bb51f82e10..a0299b188c 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -45,16 +45,17 @@ def test_publish_with_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.skip(reason="flaky because of problems with time measurement") def test_publish_with_valid_payloads_at_variable_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() + payload_desc = SAMPLE_INPUTS[0]["description"] + payload = to_base64(SAMPLE_INPUTS[0]["value"]) previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): - logger.debug(f'Running test with payload {payload["description"]}') - message = self.create_message(payload=to_base64(payload["value"])) + for i in range(0, 10): + logger.debug(f"Running test with payload {payload_desc}") + message = self.create_message(payload=payload) try: - if i % 2 == 1: # every sample with odd index is sent slowly + if i % 2 == 1: # every odd iteration is sent slowly delay(1 + 1) now = math.trunc(time()) logger.debug(f"Message sent at timestamp {now}") From a8e226360e1ceeb4003065df75cab745ec887273 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 24 Apr 2024 16:50:32 +0800 Subject: [PATCH 029/139] fix: remove the plural from payloads_at_variable_rate --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index a0299b188c..76818410c9 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -45,7 +45,7 @@ def test_publish_with_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - def test_publish_with_valid_payloads_at_variable_rate(self): + def test_publish_with_valid_payload_at_variable_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() payload_desc = SAMPLE_INPUTS[0]["description"] From 8fd9520b4d534b25b20974640f2aac7a680fb290 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 24 Apr 2024 17:13:10 +0800 Subject: [PATCH 030/139] fix: multiple class inheritance for TestRelayRLN --- src/steps/rln.py | 21 --------------------- tests/relay/test_rln.py | 7 ++++--- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 011fad3a55..8062901695 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -83,27 +83,6 @@ def publish_message(self, message=None, pubsub_topic=None, sender=None): sender.send_relay_message(message, pubsub_topic) - @allure.step - def check_published_message_reaches_relay_peer(self, message=None, pubsub_topic=None, message_propagation_delay=0.1, sender=None, peer_list=None): - if message is None: - message = self.create_message() - if pubsub_topic is None: - pubsub_topic = self.test_pubsub_topic - if not sender: - sender = self.node1 - if not peer_list: - peer_list = self.main_nodes + self.optional_nodes - - sender.send_relay_message(message, pubsub_topic) - delay(message_propagation_delay) - for index, peer in enumerate(peer_list): - logger.debug(f"Checking that peer NODE_{index + 1}:{peer.image} can find the published message") - get_messages_response = peer.get_relay_messages(pubsub_topic) - assert get_messages_response, f"Peer NODE_{index + 1}:{peer.image} couldn't find any messages" - assert len(get_messages_response) == 1, f"Expected 1 message but got {len(get_messages_response)}" - waku_message = WakuMessage(get_messages_response) - waku_message.assert_received_message(message) - @allure.step def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): for node in node_list: diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 76818410c9..2cc226c479 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -4,6 +4,7 @@ import pytest from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger +from src.steps.relay import StepsRelay from src.steps.rln import StepsRLN from src.test_data import SAMPLE_INPUTS @@ -11,7 +12,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") -class TestRelayRLN(StepsRLN): +class TestRelayRLN(StepsRLN, StepsRelay): def test_publish_with_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -104,7 +105,7 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() failed_payloads = [] - for payload in SAMPLE_INPUTS[:5]: + for payload in SAMPLE_INPUTS: logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -120,7 +121,7 @@ def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS[:4]): + for i, payload in enumerate(SAMPLE_INPUTS): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: From 0022c943d34b5a4f79ae3b268725fe3316b35b1f Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 25 Apr 2024 14:38:11 +0800 Subject: [PATCH 031/139] test: node1 with rln node2 without rln at spam rate --- src/steps/rln.py | 20 ++++++++++++++++++++ tests/relay/test_rln.py | 36 +++++++++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 8062901695..829539cec1 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -56,6 +56,26 @@ def setup_second_rln_relay_node(self, **kwargs): self.node2.add_peers([self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) + @allure.step + def setup_first_relay_node(self, **kwargs): + self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") + self.node1.start(relay="true", nodekey=NODEKEY, **kwargs) + self.enr_uri = self.node1.get_enr_uri() + self.multiaddr_with_id = self.node1.get_multiaddr_with_id() + self.main_nodes.extend([self.node1]) + + @allure.step + def setup_second_relay_node(self, **kwargs): + self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") + self.node2.start( + relay="true", + discv5_bootstrap_node=self.enr_uri, + **kwargs, + ) + if self.node2.is_nwaku(): + self.node2.add_peers([self.multiaddr_with_id]) + self.main_nodes.extend([self.node2]) + @allure.step def register_rln_single_node(self, **kwargs): logger.debug("Registering RLN credentials for single node") diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 2cc226c479..e9832b51e3 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -13,7 +13,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") class TestRelayRLN(StepsRLN, StepsRelay): - def test_publish_with_valid_payloads_at_slow_rate(self): + def test_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() failed_payloads = [] @@ -28,7 +28,7 @@ def test_publish_with_valid_payloads_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - def test_publish_with_valid_payloads_at_spam_rate(self): + def test_valid_payloads_at_spam_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() previous = math.trunc(time()) @@ -46,7 +46,7 @@ def test_publish_with_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - def test_publish_with_valid_payload_at_variable_rate(self): + def test_valid_payload_at_variable_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() payload_desc = SAMPLE_INPUTS[0]["description"] @@ -68,7 +68,7 @@ def test_publish_with_valid_payload_at_variable_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): + def test_valid_payloads_random_epoch_at_slow_rate(self): epoch_sec = random.randint(2, 5) self.setup_main_rln_relay_nodes(rln_relay_epoch_sec=epoch_sec) self.subscribe_main_relay_nodes() @@ -85,7 +85,7 @@ def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): assert not failed_payloads, f"Payloads failed: {failed_payloads}" @pytest.mark.skip(reason="waiting for RLN v2 implementation") - def test_publish_with_valid_payloads_random_user_message_limit(self): + def test_valid_payloads_random_user_message_limit(self): user_message_limit = random.randint(2, 4) self.setup_main_rln_relay_nodes(rln_relay_user_message_limit=user_message_limit) self.subscribe_main_relay_nodes() @@ -100,8 +100,8 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.timeout(700) - def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): + @pytest.mark.timeout(600) + def test_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() failed_payloads = [] @@ -116,8 +116,8 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.timeout(700) - def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): + @pytest.mark.timeout(600) + def test_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() previous = math.trunc(time()) @@ -133,3 +133,21 @@ def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): previous = now except Exception as e: assert "RLN validation failed" in str(e) + + def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): + self.setup_first_rln_relay_node() + self.setup_second_relay_node() + self.subscribe_main_relay_nodes() + previous = math.trunc(time()) + for i, payload in enumerate(SAMPLE_INPUTS): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + now = math.trunc(time()) + self.publish_message(message) + if i > 0 and (now - previous) == 0: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now + except Exception as e: + assert "RLN validation failed" in str(e) From 696b85f8989a77620dcb132d36e919399c485689 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 25 Apr 2024 15:04:19 +0800 Subject: [PATCH 032/139] test: mixed epoch at slow rate --- tests/relay/test_rln.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index e9832b51e3..6726b26e17 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -151,3 +151,22 @@ def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): previous = now except Exception as e: assert "RLN validation failed" in str(e) + + @pytest.mark.skip(reason="Peer NODE_2:harbor.status.im/wakuorg/nwaku:latest couldn't find any messages") + def test_valid_payloads_mixed_epoch_at_slow_rate(self): + n1_epoch_sec = 5 + n2_epoch_sec = 1 + self.setup_first_rln_relay_node(rln_relay_epoch_sec=n1_epoch_sec) + self.setup_second_rln_relay_node(rln_relay_epoch_sec=n2_epoch_sec) + self.subscribe_main_relay_nodes() + failed_payloads = [] + for payload in SAMPLE_INPUTS[:5]: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.check_published_message_reaches_relay_peer(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + delay(n1_epoch_sec) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" From 5b3ab1398b14caa7a646ebccb0a8552da1aa5a07 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 25 Apr 2024 22:08:09 +0800 Subject: [PATCH 033/139] test: add lightpush methods --- src/steps/rln.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 829539cec1..84e63492de 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -21,6 +21,8 @@ class StepsRLN(StepsCommon): main_nodes = [] optional_nodes = [] + multiaddr_list = [] + lightpush_nodes = [] @pytest.fixture(scope="function") def register_main_rln_relay_nodes(self, request): @@ -34,9 +36,21 @@ def setup_main_rln_relay_nodes(self, **kwargs): self.setup_second_rln_relay_node(**kwargs) @allure.step - def setup_first_rln_relay_node(self, **kwargs): + def setup_first_rln_relay_node(self, lightpush=None, **kwargs): + node_index = None + if lightpush == "true": + node_index = 1 self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") - self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1", **kwargs) + self.node1.start( + relay="true", + nodekey=NODEKEY, + rln_creds_source=RLN_CREDENTIALS, + rln_creds_id="1", + rln_relay_membership_index="1", + node_index=node_index, + lightpush=lightpush, + **kwargs, + ) self.enr_uri = self.node1.get_enr_uri() self.multiaddr_with_id = self.node1.get_multiaddr_with_id() self.main_nodes.extend([self.node1]) @@ -56,6 +70,15 @@ def setup_second_rln_relay_node(self, **kwargs): self.node2.add_peers([self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) + @allure.step + def setup_lightpush_node(self, relay=None, **kwargs): + self.light_push_node1 = WakuNode(DEFAULT_NWAKU, f"lightpush_node2_{self.test_id}") + self.light_push_node1.start(relay=relay, discv5_bootstrap_node=self.enr_uri, node_index=2, lightpushnode=self.multiaddr_list[0], **kwargs) + if relay == "true": + self.main_nodes.extend([self.light_push_node1]) + self.lightpush_nodes.extend([self.light_push_node1]) + self.add_node_peer(self.light_push_node1, self.multiaddr_list) + @allure.step def setup_first_relay_node(self, **kwargs): self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") @@ -103,6 +126,17 @@ def publish_message(self, message=None, pubsub_topic=None, sender=None): sender.send_relay_message(message, pubsub_topic) + def publish_light_push_message(self, message=None, pubsub_topic=None, sender=None): + if message is None: + message = self.create_message() + if pubsub_topic is None: + pubsub_topic = self.test_pubsub_topic + if not sender: + sender = self.node1 + + payload = self.create_payload(pubsub_topic, message) + sender.send_light_push_message(payload) + @allure.step def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): for node in node_list: @@ -111,3 +145,36 @@ def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): @allure.step def subscribe_main_relay_nodes(self): self.ensure_relay_subscriptions_on_nodes(self.main_nodes, [self.test_pubsub_topic]) + + @allure.step + def create_payload(self, pubsub_topic=None, message=None, **kwargs): + if message is None: + message = self.create_message() + if pubsub_topic is None: + pubsub_topic = self.test_pubsub_topic + payload = {"pubsubTopic": pubsub_topic, "message": message} + payload.update(kwargs) + return payload + + @allure.step + def check_light_pushed_message_reaches_receiving_peer( + self, pubsub_topic=None, message=None, message_propagation_delay=0.1, sender=None, peer_list=None + ): + if pubsub_topic is None: + pubsub_topic = self.test_pubsub_topic + if not sender: + sender = self.node1 + if not peer_list: + peer_list = self.main_nodes + self.optional_nodes + + payload = self.create_payload(pubsub_topic, message) + logger.debug("Lightpushing message") + sender.send_light_push_message(payload) + delay(message_propagation_delay) + for index, peer in enumerate(peer_list): + logger.debug(f"Checking that peer NODE_{index + 1}:{peer.image} can find the lightpushed message") + get_messages_response = peer.get_relay_messages(pubsub_topic) + assert get_messages_response, f"Peer NODE_{index + 1}:{peer.image} couldn't find any messages" + assert len(get_messages_response) == 1, f"Expected 1 message but got {len(get_messages_response)}" + waku_message = WakuMessage(get_messages_response) + waku_message.assert_received_message(payload["message"]) From 7f86deb0c37d49dffb78ee165c78a67d8f11c03c Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 25 Apr 2024 22:12:32 +0800 Subject: [PATCH 034/139] test: send valid payloads lightpush at spam rate --- tests/relay/test_rln.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 6726b26e17..3fe9de423b 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -170,3 +170,22 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): failed_payloads.append(payload["description"]) delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + @pytest.mark.skip(reason="Cannot start RLN relay with lightpush enabled") + def test_valid_payloads_lightpush_at_spam_rate(self): + self.setup_first_rln_relay_node(lightpush="true") # with lightpush enabled + self.setup_lightpush_node() + self.subscribe_main_relay_nodes() + previous = math.trunc(time()) + for i, payload in enumerate(SAMPLE_INPUTS): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + now = math.trunc(time()) + self.publish_light_push_message(message=message, sender=self.light_push_node1) + if i > 0 and (now - previous) == 0: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now + except Exception as e: + assert "RLN validation failed" in str(e) From b6e14e54d67542ee35e2e11e2a6a70d75b8b2131 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 13:30:53 +0800 Subject: [PATCH 035/139] fix: node1 to act as light push receiving node - add setup lightpush node to spin off node2 with lightpush support --- src/steps/rln.py | 26 ++++++++++++-------------- tests/relay/test_rln.py | 8 ++++---- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 84e63492de..a6b5a1b942 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -37,9 +37,6 @@ def setup_main_rln_relay_nodes(self, **kwargs): @allure.step def setup_first_rln_relay_node(self, lightpush=None, **kwargs): - node_index = None - if lightpush == "true": - node_index = 1 self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") self.node1.start( relay="true", @@ -47,7 +44,6 @@ def setup_first_rln_relay_node(self, lightpush=None, **kwargs): rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1", - node_index=node_index, lightpush=lightpush, **kwargs, ) @@ -55,6 +51,9 @@ def setup_first_rln_relay_node(self, lightpush=None, **kwargs): self.multiaddr_with_id = self.node1.get_multiaddr_with_id() self.main_nodes.extend([self.node1]) + self.add_node_peer(self.node1, self.multiaddr_list) + self.multiaddr_list.extend([self.node1.get_multiaddr_with_id()]) + @allure.step def setup_second_rln_relay_node(self, **kwargs): self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") @@ -66,18 +65,18 @@ def setup_second_rln_relay_node(self, **kwargs): rln_relay_membership_index="1", **kwargs, ) - if self.node2.is_nwaku(): - self.node2.add_peers([self.multiaddr_with_id]) + + self.add_node_peer(self.node2, [self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) @allure.step - def setup_lightpush_node(self, relay=None, **kwargs): - self.light_push_node1 = WakuNode(DEFAULT_NWAKU, f"lightpush_node2_{self.test_id}") - self.light_push_node1.start(relay=relay, discv5_bootstrap_node=self.enr_uri, node_index=2, lightpushnode=self.multiaddr_list[0], **kwargs) + def setup_second_lightpush_node(self, relay="false", **kwargs): + self.light_push_node2 = WakuNode(DEFAULT_NWAKU, f"lightpush_node2_{self.test_id}") + self.light_push_node2.start(relay=relay, discv5_bootstrap_node=self.enr_uri, lightpush="true", lightpushnode=self.multiaddr_list[0], **kwargs) if relay == "true": - self.main_nodes.extend([self.light_push_node1]) - self.lightpush_nodes.extend([self.light_push_node1]) - self.add_node_peer(self.light_push_node1, self.multiaddr_list) + self.main_nodes.extend([self.light_push_node2]) + self.lightpush_nodes.extend([self.light_push_node2]) + self.add_node_peer(self.light_push_node2, self.multiaddr_list) @allure.step def setup_first_relay_node(self, **kwargs): @@ -95,8 +94,7 @@ def setup_second_relay_node(self, **kwargs): discv5_bootstrap_node=self.enr_uri, **kwargs, ) - if self.node2.is_nwaku(): - self.node2.add_peers([self.multiaddr_with_id]) + self.add_node_peer(self.node2, [self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) @allure.step diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 3fe9de423b..7652c0b146 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -171,10 +171,10 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="Cannot start RLN relay with lightpush enabled") + @pytest.mark.skip(reason="Lightpush node is not adding RLN proofs yet - TBT with Gowaku") def test_valid_payloads_lightpush_at_spam_rate(self): - self.setup_first_rln_relay_node(lightpush="true") # with lightpush enabled - self.setup_lightpush_node() + self.setup_first_rln_relay_node(lightpush="true") + self.setup_second_lightpush_node() self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS): @@ -182,7 +182,7 @@ def test_valid_payloads_lightpush_at_spam_rate(self): message = self.create_message(payload=to_base64(payload["value"])) try: now = math.trunc(time()) - self.publish_light_push_message(message=message, sender=self.light_push_node1) + self.publish_light_push_message(message=message, sender=self.light_push_node2) if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") else: From e877df7e965542c15053f8e703e5b2cfd8f88657 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 15:32:09 +0800 Subject: [PATCH 036/139] fix: use NODE1 NODE2 instead of DEFAULT_NWAKU --- src/steps/rln.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index a6b5a1b942..5ce3838c78 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -6,7 +6,7 @@ from src.node.waku_message import WakuMessage from src.steps.common import StepsCommon from src.test_data import PUBSUB_TOPICS_RLN -from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY, NODE_1, NODE_2 from src.libs.common import gen_step_id, delay from src.libs.custom_logger import get_custom_logger from src.node.waku_node import WakuNode, rln_credential_store_ready @@ -37,7 +37,7 @@ def setup_main_rln_relay_nodes(self, **kwargs): @allure.step def setup_first_rln_relay_node(self, lightpush=None, **kwargs): - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") + self.node1 = WakuNode(NODE_1, f"node1_{self.test_id}") self.node1.start( relay="true", nodekey=NODEKEY, @@ -56,7 +56,7 @@ def setup_first_rln_relay_node(self, lightpush=None, **kwargs): @allure.step def setup_second_rln_relay_node(self, **kwargs): - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") + self.node2 = WakuNode(NODE_2, f"node2_{self.test_id}") self.node2.start( relay="true", discv5_bootstrap_node=self.enr_uri, @@ -71,7 +71,7 @@ def setup_second_rln_relay_node(self, **kwargs): @allure.step def setup_second_lightpush_node(self, relay="false", **kwargs): - self.light_push_node2 = WakuNode(DEFAULT_NWAKU, f"lightpush_node2_{self.test_id}") + self.light_push_node2 = WakuNode(NODE_2, f"lightpush_node2_{self.test_id}") self.light_push_node2.start(relay=relay, discv5_bootstrap_node=self.enr_uri, lightpush="true", lightpushnode=self.multiaddr_list[0], **kwargs) if relay == "true": self.main_nodes.extend([self.light_push_node2]) @@ -80,7 +80,7 @@ def setup_second_lightpush_node(self, relay="false", **kwargs): @allure.step def setup_first_relay_node(self, **kwargs): - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") + self.node1 = WakuNode(NODE_1, f"node1_{self.test_id}") self.node1.start(relay="true", nodekey=NODEKEY, **kwargs) self.enr_uri = self.node1.get_enr_uri() self.multiaddr_with_id = self.node1.get_multiaddr_with_id() @@ -88,7 +88,7 @@ def setup_first_relay_node(self, **kwargs): @allure.step def setup_second_relay_node(self, **kwargs): - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") + self.node2 = WakuNode(NODE_2, f"node2_{self.test_id}") self.node2.start( relay="true", discv5_bootstrap_node=self.enr_uri, From 345f3f57d87f77f50e71adac474963752c0ea67e Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 16:30:34 +0800 Subject: [PATCH 037/139] fix: no lightpush param required for plain RLN relay --- src/steps/rln.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 5ce3838c78..7f3b4544bc 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -36,7 +36,7 @@ def setup_main_rln_relay_nodes(self, **kwargs): self.setup_second_rln_relay_node(**kwargs) @allure.step - def setup_first_rln_relay_node(self, lightpush=None, **kwargs): + def setup_first_rln_relay_node(self, **kwargs): self.node1 = WakuNode(NODE_1, f"node1_{self.test_id}") self.node1.start( relay="true", @@ -44,14 +44,12 @@ def setup_first_rln_relay_node(self, lightpush=None, **kwargs): rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1", - lightpush=lightpush, **kwargs, ) self.enr_uri = self.node1.get_enr_uri() self.multiaddr_with_id = self.node1.get_multiaddr_with_id() self.main_nodes.extend([self.node1]) - self.add_node_peer(self.node1, self.multiaddr_list) self.multiaddr_list.extend([self.node1.get_multiaddr_with_id()]) @allure.step @@ -65,7 +63,6 @@ def setup_second_rln_relay_node(self, **kwargs): rln_relay_membership_index="1", **kwargs, ) - self.add_node_peer(self.node2, [self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) From 939c0b509d1397b757af0ed43124415816333893 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 16:35:31 +0800 Subject: [PATCH 038/139] fix: comment for lightpush --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 7652c0b146..e8c328a085 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -171,7 +171,7 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="Lightpush node is not adding RLN proofs yet - TBT with Gowaku") + @pytest.mark.skip(reason="NWAKU lightpush node not adding RLN proofs yet - TBT with Gowaku") def test_valid_payloads_lightpush_at_spam_rate(self): self.setup_first_rln_relay_node(lightpush="true") self.setup_second_lightpush_node() From 7e415f6a5f808c2e03a0c2405e8f0a7dc1fec0e9 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 17:00:48 +0800 Subject: [PATCH 039/139] fix: comment for lightpush - wait for implementation --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index e8c328a085..90657eb470 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -171,7 +171,7 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="NWAKU lightpush node not adding RLN proofs yet - TBT with Gowaku") + @pytest.mark.skip(reason="waiting for NWAKU lightpush + RLN node implementation") def test_valid_payloads_lightpush_at_spam_rate(self): self.setup_first_rln_relay_node(lightpush="true") self.setup_second_lightpush_node() From f9693755d0bf6a9d8cf42e1a9ab4e093a5ea48ed Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 17:07:57 +0800 Subject: [PATCH 040/139] fix: comment on chain tests --- tests/relay/test_rln.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 90657eb470..63797f9a03 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -100,6 +100,7 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") @@ -116,6 +117,7 @@ def test_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") From 00eeaa553e543f39588201a19d9a77b13a0b935a Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 29 Apr 2024 11:54:21 +0800 Subject: [PATCH 041/139] fix: add lightpush case to publish_message --- src/steps/rln.py | 19 ++++++------------- tests/relay/test_rln.py | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 7f3b4544bc..51a49ca26e 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -111,7 +111,7 @@ def check_rln_registration(self, key_id): raise @allure.step - def publish_message(self, message=None, pubsub_topic=None, sender=None): + def publish_message(self, message=None, pubsub_topic=None, sender=None, use_lightpush=False): if message is None: message = self.create_message() if pubsub_topic is None: @@ -119,18 +119,11 @@ def publish_message(self, message=None, pubsub_topic=None, sender=None): if not sender: sender = self.node1 - sender.send_relay_message(message, pubsub_topic) - - def publish_light_push_message(self, message=None, pubsub_topic=None, sender=None): - if message is None: - message = self.create_message() - if pubsub_topic is None: - pubsub_topic = self.test_pubsub_topic - if not sender: - sender = self.node1 - - payload = self.create_payload(pubsub_topic, message) - sender.send_light_push_message(payload) + if use_lightpush: + payload = self.create_payload(pubsub_topic, message) + sender.send_light_push_message(payload) + else: + sender.send_relay_message(message, pubsub_topic) @allure.step def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 63797f9a03..3806377f40 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -184,7 +184,7 @@ def test_valid_payloads_lightpush_at_spam_rate(self): message = self.create_message(payload=to_base64(payload["value"])) try: now = math.trunc(time()) - self.publish_light_push_message(message=message, sender=self.light_push_node2) + self.publish_message(message=message, sender=self.light_push_node2, use_lightpush=True) if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") else: From f67a73eb75138e8ce92af1c0a05bb19ed60b6ba6 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 29 Apr 2024 12:05:12 +0800 Subject: [PATCH 042/139] fix: remove check_light_pushed_message_reaches_receiving_peer from StepsRLN --- src/steps/rln.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 51a49ca26e..01919bfaaa 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -143,26 +143,3 @@ def create_payload(self, pubsub_topic=None, message=None, **kwargs): payload = {"pubsubTopic": pubsub_topic, "message": message} payload.update(kwargs) return payload - - @allure.step - def check_light_pushed_message_reaches_receiving_peer( - self, pubsub_topic=None, message=None, message_propagation_delay=0.1, sender=None, peer_list=None - ): - if pubsub_topic is None: - pubsub_topic = self.test_pubsub_topic - if not sender: - sender = self.node1 - if not peer_list: - peer_list = self.main_nodes + self.optional_nodes - - payload = self.create_payload(pubsub_topic, message) - logger.debug("Lightpushing message") - sender.send_light_push_message(payload) - delay(message_propagation_delay) - for index, peer in enumerate(peer_list): - logger.debug(f"Checking that peer NODE_{index + 1}:{peer.image} can find the lightpushed message") - get_messages_response = peer.get_relay_messages(pubsub_topic) - assert get_messages_response, f"Peer NODE_{index + 1}:{peer.image} couldn't find any messages" - assert len(get_messages_response) == 1, f"Expected 1 message but got {len(get_messages_response)}" - waku_message = WakuMessage(get_messages_response) - waku_message.assert_received_message(payload["message"]) From ee2e05679e5aff0dc2c8f43674883d257bb92a47 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 09:56:11 +0800 Subject: [PATCH 043/139] fix: change comment for mixed_epoch_at_slow_rate --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 3806377f40..24979f9a1b 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -154,7 +154,7 @@ def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.skip(reason="Peer NODE_2:harbor.status.im/wakuorg/nwaku:latest couldn't find any messages") + @pytest.mark.skip(reason="Epoch settings aren't compatible across nodes") def test_valid_payloads_mixed_epoch_at_slow_rate(self): n1_epoch_sec = 5 n2_epoch_sec = 1 From 58f89c64749a1d4192fa7af263bff6c8cf8b8cc9 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 14:14:53 +0800 Subject: [PATCH 044/139] test: happy and common case with 5 nodes --- src/steps/rln.py | 35 ++++++++++++++++++++++++++++++++++- tests/relay/test_rln.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 01919bfaaa..17337eb04c 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -6,7 +6,7 @@ from src.node.waku_message import WakuMessage from src.steps.common import StepsCommon from src.test_data import PUBSUB_TOPICS_RLN -from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY, NODE_1, NODE_2 +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY, NODE_1, NODE_2, ADDITIONAL_NODES from src.libs.common import gen_step_id, delay from src.libs.custom_logger import get_custom_logger from src.node.waku_node import WakuNode, rln_credential_store_ready @@ -30,6 +30,13 @@ def register_main_rln_relay_nodes(self, request): self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") + @pytest.fixture(scope="function") + def register_optional_rln_relay_nodes(self, request): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") + self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="3") + self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="4") + self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="5") + @allure.step def setup_main_rln_relay_nodes(self, **kwargs): self.setup_first_rln_relay_node(**kwargs) @@ -66,6 +73,28 @@ def setup_second_rln_relay_node(self, **kwargs): self.add_node_peer(self.node2, [self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) + @allure.step + def setup_optional_rln_relay_nodes(self, **kwargs): + if ADDITIONAL_NODES: + nodes = [node.strip() for node in ADDITIONAL_NODES.split(",")] + else: + pytest.skip("ADDITIONAL_NODES is empty, cannot run test") + if len(nodes) > 3: + logger.debug("More than 3 nodes are not supported for RLN tests, using first 3") + nodes = nodes[:3] + for index, node in enumerate(nodes): + node = WakuNode(node, f"node{index + 3}_{self.test_id}") + node.start( + relay="true", + discv5_bootstrap_node=self.enr_uri, + rln_creds_source=RLN_CREDENTIALS, + rln_creds_id=f"{index + 3}", + rln_relay_membership_index="1", + **kwargs, + ) + self.add_node_peer(node, [self.multiaddr_with_id]) + self.optional_nodes.append(node) + @allure.step def setup_second_lightpush_node(self, relay="false", **kwargs): self.light_push_node2 = WakuNode(NODE_2, f"lightpush_node2_{self.test_id}") @@ -134,6 +163,10 @@ def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): def subscribe_main_relay_nodes(self): self.ensure_relay_subscriptions_on_nodes(self.main_nodes, [self.test_pubsub_topic]) + @allure.step + def subscribe_optional_relay_nodes(self): + self.ensure_relay_subscriptions_on_nodes(self.optional_nodes, [self.test_pubsub_topic]) + @allure.step def create_payload(self, pubsub_topic=None, message=None, **kwargs): if message is None: diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 24979f9a1b..9fe9b335d5 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -191,3 +191,41 @@ def test_valid_payloads_lightpush_at_spam_rate(self): previous = now except Exception as e: assert "RLN validation failed" in str(e) + + @pytest.mark.usefixtures("register_optional_rln_relay_nodes") + def test_valid_payloads_with_optional_nodes_at_slow_rate(self): + self.setup_main_rln_relay_nodes() + self.setup_optional_rln_relay_nodes() + self.subscribe_main_relay_nodes() + self.subscribe_optional_relay_nodes() + failed_payloads = [] + for payload in SAMPLE_INPUTS: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.check_published_message_reaches_relay_peer(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + delay(1) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + @pytest.mark.usefixtures("register_optional_rln_relay_nodes") + def test_valid_payloads_with_optional_nodes_at_spam_rate(self): + self.setup_main_rln_relay_nodes() + self.setup_optional_rln_relay_nodes() + self.subscribe_main_relay_nodes() + self.subscribe_optional_relay_nodes() + previous = math.trunc(time()) + for i, payload in enumerate(SAMPLE_INPUTS): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + now = math.trunc(time()) + self.publish_message(message) + if i > 0 and (now - previous) == 0: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now + except Exception as e: + assert "RLN validation failed" in str(e) From f4a50ca6b552a181a3d1ca34d992d4ce7bf845b4 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 14:17:20 +0800 Subject: [PATCH 045/139] fix: add all required fixtures explicitly --- tests/relay/test_rln.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 9fe9b335d5..48a9420860 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -192,7 +192,7 @@ def test_valid_payloads_lightpush_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.usefixtures("register_optional_rln_relay_nodes") + @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.setup_optional_rln_relay_nodes() @@ -210,7 +210,7 @@ def test_valid_payloads_with_optional_nodes_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.usefixtures("register_optional_rln_relay_nodes") + @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_spam_rate(self): self.setup_main_rln_relay_nodes() self.setup_optional_rln_relay_nodes() From 3dcc00c094f39a2227ad23172ea7ce9b5ca7b711 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 18:33:17 +0800 Subject: [PATCH 046/139] fix: add timeout param to ensure_ready --- src/node/waku_node.py | 17 ++++++++++------- tests/relay/test_rln.py | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/node/waku_node.py b/src/node/waku_node.py index d965725f32..16d53f8c62 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -48,7 +48,7 @@ def __init__(self, docker_image, docker_log_prefix=""): logger.debug(f"WakuNode instance initialized with log path {self._log_path}") @retry(stop=stop_after_delay(5), wait=wait_fixed(0.1), reraise=True) - def start(self, **kwargs): + def start(self, wait_for_node_sec=10, **kwargs): logger.debug("Starting Node...") self._docker_manager.create_network() self._ext_ip = self._docker_manager.generate_random_ext_ip() @@ -122,7 +122,7 @@ def start(self, **kwargs): DS.waku_nodes.append(self) delay(1) # if we fire requests to soon after starting the node will sometimes fail to start correctly try: - self.ensure_ready() + self.ensure_ready(timeout_duration=wait_for_node_sec) except Exception as ex: logger.error(f"REST service did not become ready in time: {ex}") raise @@ -185,12 +185,15 @@ def unpause(self): logger.debug(f"Unpause container with id {self._container.short_id}") self._container.unpause() - @retry(stop=stop_after_delay(600), wait=wait_fixed(1), reraise=True) - def ensure_ready(self): - self.info_response = self.info() - logger.info("REST service is ready !!") + def ensure_ready(self, timeout_duration=10): + @retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(0.1), reraise=True) + def check_ready(node=self): + node.info_response = node.info() + logger.info("REST service is ready !!") - @retry(stop=stop_after_delay(600), wait=wait_fixed(1), reraise=True) + check_ready() + + @retry(stop=stop_after_delay(10), wait=wait_fixed(1), reraise=True) def ensure_healthy(self): self.health_response = self.health() logger.info("Node is healthy !!") diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 48a9420860..e0c4e74806 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -103,7 +103,7 @@ def test_valid_payloads_random_user_message_limit(self): @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): - self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") + self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS: @@ -120,7 +120,7 @@ def test_valid_payloads_dynamic_at_slow_rate(self): @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_spam_rate(self): - self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") + self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS): From ab63244300aa80f22eaad2e7aa74073bbfdce540 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 19:57:22 +0800 Subject: [PATCH 047/139] fix: skip RLN tests for go-waku --- tests/relay/test_rln.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index e0c4e74806..c0de411cd8 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -2,6 +2,8 @@ import random from time import time import pytest + +from src.env_vars import NODE_1, NODE_2 from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger from src.steps.relay import StepsRelay @@ -12,6 +14,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") +@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku") class TestRelayRLN(StepsRLN, StepsRelay): def test_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() From 1e463cdd53c63bc64e1c9377d9c6cbafec03f5b3 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 20:11:59 +0800 Subject: [PATCH 048/139] fix: reformated with pre-commit --- src/steps/relay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/steps/relay.py b/src/steps/relay.py index c84ac49e44..f61fe6b704 100644 --- a/src/steps/relay.py +++ b/src/steps/relay.py @@ -41,7 +41,7 @@ def setup_main_relay_nodes(self, request): self.node2.start(relay="true", discv5_bootstrap_node=self.enr_uri) self.add_node_peer(self.node2, [self.multiaddr_with_id]) self.main_nodes.extend([self.node1, self.node2]) - + @pytest.fixture(scope="function") def setup_optional_relay_nodes(self, request): logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") From 73d09518c77923c29a88a2373a82ff7c5f8c3bab Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 3 May 2024 13:54:28 +0800 Subject: [PATCH 049/139] fix: uncomment skip for debugging --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index c0de411cd8..12421791f5 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -103,7 +103,7 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") + # @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) From d3e14e05553fe8555d28c7295287778d6d7b9d67 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 3 May 2024 14:23:15 +0800 Subject: [PATCH 050/139] fix: put the skip back --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 12421791f5..c0de411cd8 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -103,7 +103,7 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - # @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") + @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) From 266143886d8033183e5d8c748a9cdb444cb85776 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 10:31:09 +0800 Subject: [PATCH 051/139] fix: change comment for on chain tests --- tests/relay/test_rln.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index c0de411cd8..5240b399aa 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -103,7 +103,7 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") + @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) @@ -120,7 +120,7 @@ def test_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") + @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) From f108cb9ab382e0c22b49ed42e7f2603e39dcbd7e Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 13:33:12 +0800 Subject: [PATCH 052/139] fix: run RLN tests in serial - add grouping of tests to runner - use smaller dataset for spam rate tests --- .github/workflows/test_common.yml | 2 +- tests/relay/test_rln.py | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 1774d891c5..6863cff44f 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -49,7 +49,7 @@ jobs: - run: pip install -r requirements.txt - name: Run tests - run: pytest -n 4 --reruns 2 --alluredir=allure-results + run: pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 5240b399aa..aecd637a21 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -16,6 +16,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") @pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku") class TestRelayRLN(StepsRLN, StepsRelay): + @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -31,11 +32,12 @@ def test_valid_payloads_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_at_spam_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): + for i, payload in enumerate(SAMPLE_INPUTS[:5]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -49,6 +51,7 @@ def test_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payload_at_variable_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -71,6 +74,7 @@ def test_valid_payload_at_variable_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_random_epoch_at_slow_rate(self): epoch_sec = random.randint(2, 5) self.setup_main_rln_relay_nodes(rln_relay_epoch_sec=epoch_sec) @@ -87,6 +91,7 @@ def test_valid_payloads_random_epoch_at_slow_rate(self): delay(epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="waiting for RLN v2 implementation") def test_valid_payloads_random_user_message_limit(self): user_message_limit = random.randint(2, 4) @@ -103,6 +108,7 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): @@ -120,13 +126,14 @@ def test_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): + for i, payload in enumerate(SAMPLE_INPUTS[:5]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -139,12 +146,13 @@ def test_valid_payloads_dynamic_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): self.setup_first_rln_relay_node() self.setup_second_relay_node() self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): + for i, payload in enumerate(SAMPLE_INPUTS[:5]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -157,6 +165,7 @@ def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="Epoch settings aren't compatible across nodes") def test_valid_payloads_mixed_epoch_at_slow_rate(self): n1_epoch_sec = 5 @@ -176,13 +185,14 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="waiting for NWAKU lightpush + RLN node implementation") def test_valid_payloads_lightpush_at_spam_rate(self): self.setup_first_rln_relay_node(lightpush="true") self.setup_second_lightpush_node() self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): + for i, payload in enumerate(SAMPLE_INPUTS[:5]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -195,6 +205,7 @@ def test_valid_payloads_lightpush_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_slow_rate(self): self.setup_main_rln_relay_nodes() @@ -213,6 +224,7 @@ def test_valid_payloads_with_optional_nodes_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_spam_rate(self): self.setup_main_rln_relay_nodes() @@ -220,7 +232,7 @@ def test_valid_payloads_with_optional_nodes_at_spam_rate(self): self.subscribe_main_relay_nodes() self.subscribe_optional_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): + for i, payload in enumerate(SAMPLE_INPUTS[:5]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: From c00ff1a252510ec3a70d12605f47ef8cc9718aab Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 13:41:44 +0800 Subject: [PATCH 053/139] test: Nim to Nim workflow --- .github/workflows/nim_waku_daily_test.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/nim_waku_daily_test.yml diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml new file mode 100644 index 0000000000..e4bf8f9677 --- /dev/null +++ b/.github/workflows/nim_waku_daily_test.yml @@ -0,0 +1,20 @@ +name: Test Nim -> Nim Waku Interop Tests + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: false + +on: + push: + branches: + - chore-rln-relay-tests + workflow_dispatch: + +jobs: + test-common: + uses: ./.github/workflows/test_common.yml + secrets: inherit + with: + node1: "harbor.status.im/wakuorg/nwaku:latest" + node2: "harbor.status.im/wakuorg/nwaku:latest" + caller: "nim" From 24f6674fea3354290daa0a12f0090b4e0982ded4 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 14:04:59 +0800 Subject: [PATCH 054/139] test: check also additional nodes for go-waku --- tests/relay/test_rln.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index aecd637a21..1ada793ec0 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -3,7 +3,7 @@ from time import time import pytest -from src.env_vars import NODE_1, NODE_2 +from src.env_vars import NODE_1, NODE_2, ADDITIONAL_NODES from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger from src.steps.relay import StepsRelay @@ -14,7 +14,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") -@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku") +@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2 + ADDITIONAL_NODES), reason="Test works only with nwaku") class TestRelayRLN(StepsRLN, StepsRelay): @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_at_slow_rate(self): From cb2632c3ecf3f036e9a095aacbc2c6df18eb0c73 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 14:26:45 +0800 Subject: [PATCH 055/139] test: all nodes are nwaku --- .github/workflows/nim_waku_daily_test.yml | 1 + .github/workflows/test_common.yml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml index e4bf8f9677..b182bcce84 100644 --- a/.github/workflows/nim_waku_daily_test.yml +++ b/.github/workflows/nim_waku_daily_test.yml @@ -17,4 +17,5 @@ jobs: with: node1: "harbor.status.im/wakuorg/nwaku:latest" node2: "harbor.status.im/wakuorg/nwaku:latest" + additional_nodes: "harbor.status.im/wakuorg/nwaku:latest","harbor.status.im/wakuorg/nwaku:latest","harbor.status.im/wakuorg/nwaku:latest" caller: "nim" diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 6863cff44f..f6e1b5ffc2 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -100,12 +100,12 @@ jobs: echo EOF } >> $GITHUB_ENV - - name: Send report to Discord - uses: rjstone/discord-webhook-notify@v1 - if: always() && env.CALLER != 'manual' - with: - severity: ${{ job.status == 'success' && 'info' || 'error' }} - username: ${{ github.workflow }} - description: "## Job Result: ${{ job.status }}" - details: ${{ env.JOB_SUMMARY }} - webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} +# - name: Send report to Discord +# uses: rjstone/discord-webhook-notify@v1 +# if: always() && env.CALLER != 'manual' +# with: +# severity: ${{ job.status == 'success' && 'info' || 'error' }} +# username: ${{ github.workflow }} +# description: "## Job Result: ${{ job.status }}" +# details: ${{ env.JOB_SUMMARY }} +# webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} From 1ab141f2dc9ff92e1e01ecec727fe24344a85eac Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 14:29:40 +0800 Subject: [PATCH 056/139] fix: string quotes --- .github/workflows/nim_waku_daily_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml index b182bcce84..89084219cf 100644 --- a/.github/workflows/nim_waku_daily_test.yml +++ b/.github/workflows/nim_waku_daily_test.yml @@ -17,5 +17,5 @@ jobs: with: node1: "harbor.status.im/wakuorg/nwaku:latest" node2: "harbor.status.im/wakuorg/nwaku:latest" - additional_nodes: "harbor.status.im/wakuorg/nwaku:latest","harbor.status.im/wakuorg/nwaku:latest","harbor.status.im/wakuorg/nwaku:latest" + additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" caller: "nim" From 1423e539e4cf3bd660ecf88a2cb4ca1b09b1083a Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 15:40:51 +0800 Subject: [PATCH 057/139] fix: remove additional nodes --- .github/workflows/nim_waku_daily_test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml index 89084219cf..e4bf8f9677 100644 --- a/.github/workflows/nim_waku_daily_test.yml +++ b/.github/workflows/nim_waku_daily_test.yml @@ -17,5 +17,4 @@ jobs: with: node1: "harbor.status.im/wakuorg/nwaku:latest" node2: "harbor.status.im/wakuorg/nwaku:latest" - additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" caller: "nim" From 78043022fe26565f78628665d74e6eb873baaacb Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 17:44:13 +0800 Subject: [PATCH 058/139] fix: re-arrange skip conditions --- tests/relay/test_rln.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 1ada793ec0..4cf3897285 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -13,10 +13,10 @@ logger = get_custom_logger(__name__) +@pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.usefixtures("register_main_rln_relay_nodes") -@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2 + ADDITIONAL_NODES), reason="Test works only with nwaku") +@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku") class TestRelayRLN(StepsRLN, StepsRelay): - @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -32,7 +32,6 @@ def test_valid_payloads_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_at_spam_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -51,7 +50,6 @@ def test_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payload_at_variable_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -74,7 +72,6 @@ def test_valid_payload_at_variable_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_random_epoch_at_slow_rate(self): epoch_sec = random.randint(2, 5) self.setup_main_rln_relay_nodes(rln_relay_epoch_sec=epoch_sec) @@ -91,7 +88,6 @@ def test_valid_payloads_random_epoch_at_slow_rate(self): delay(epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="waiting for RLN v2 implementation") def test_valid_payloads_random_user_message_limit(self): user_message_limit = random.randint(2, 4) @@ -108,7 +104,6 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): @@ -126,7 +121,6 @@ def test_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_spam_rate(self): @@ -146,7 +140,6 @@ def test_valid_payloads_dynamic_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): self.setup_first_rln_relay_node() self.setup_second_relay_node() @@ -165,7 +158,6 @@ def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="Epoch settings aren't compatible across nodes") def test_valid_payloads_mixed_epoch_at_slow_rate(self): n1_epoch_sec = 5 @@ -185,7 +177,6 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="waiting for NWAKU lightpush + RLN node implementation") def test_valid_payloads_lightpush_at_spam_rate(self): self.setup_first_rln_relay_node(lightpush="true") @@ -205,7 +196,7 @@ def test_valid_payloads_lightpush_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.xdist_group(name="RLN serial tests") + @pytest.mark.skipif("go-waku" in ADDITIONAL_NODES, reason="Test works only with nwaku") @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_slow_rate(self): self.setup_main_rln_relay_nodes() @@ -224,7 +215,7 @@ def test_valid_payloads_with_optional_nodes_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") + @pytest.mark.skipif("go-waku" in ADDITIONAL_NODES, reason="Test works only with nwaku") @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_spam_rate(self): self.setup_main_rln_relay_nodes() From 842f7ceea5f5057c891f29e871946a4961f3a65e Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 17:44:59 +0800 Subject: [PATCH 059/139] test: RLN only --- .github/workflows/test_common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index f6e1b5ffc2..15b46fe492 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -49,7 +49,7 @@ jobs: - run: pip install -r requirements.txt - name: Run tests - run: pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + run: pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() From 437964230453b797fd09d28af8624042818083c1 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 18:08:36 +0800 Subject: [PATCH 060/139] fix: change default additional nodes to nwaku only --- src/env_vars.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/env_vars.py b/src/env_vars.py index a588185616..4c220b7b43 100644 --- a/src/env_vars.py +++ b/src/env_vars.py @@ -18,7 +18,7 @@ def get_env_var(var_name, default=None): DEFAULT_GOWAKU = "harbor.status.im/wakuorg/go-waku:latest" NODE_1 = get_env_var("NODE_1", DEFAULT_GOWAKU) NODE_2 = get_env_var("NODE_2", DEFAULT_NWAKU) -ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_GOWAKU},{DEFAULT_NWAKU}") +ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_NWAKU},{DEFAULT_NWAKU}") # more nodes need to follow the NODE_X pattern DOCKER_LOG_DIR = get_env_var("DOCKER_LOG_DIR", "./log/docker") NETWORK_NAME = get_env_var("NETWORK_NAME", "waku") From 3452bed31bc136102fff458afa1f5d5e64a148aa Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 18:30:23 +0800 Subject: [PATCH 061/139] fix: change additional nodes rather at top level workflow --- .github/workflows/nim_waku_daily_test.yml | 1 + src/env_vars.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml index e4bf8f9677..89084219cf 100644 --- a/.github/workflows/nim_waku_daily_test.yml +++ b/.github/workflows/nim_waku_daily_test.yml @@ -17,4 +17,5 @@ jobs: with: node1: "harbor.status.im/wakuorg/nwaku:latest" node2: "harbor.status.im/wakuorg/nwaku:latest" + additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" caller: "nim" diff --git a/src/env_vars.py b/src/env_vars.py index 4c220b7b43..a588185616 100644 --- a/src/env_vars.py +++ b/src/env_vars.py @@ -18,7 +18,7 @@ def get_env_var(var_name, default=None): DEFAULT_GOWAKU = "harbor.status.im/wakuorg/go-waku:latest" NODE_1 = get_env_var("NODE_1", DEFAULT_GOWAKU) NODE_2 = get_env_var("NODE_2", DEFAULT_NWAKU) -ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_NWAKU},{DEFAULT_NWAKU}") +ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_GOWAKU},{DEFAULT_NWAKU}") # more nodes need to follow the NODE_X pattern DOCKER_LOG_DIR = get_env_var("DOCKER_LOG_DIR", "./log/docker") NETWORK_NAME = get_env_var("NETWORK_NAME", "waku") From 2db8c3877ee6753467b02e2c9023f864587ea2ec Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 18:41:34 +0800 Subject: [PATCH 062/139] fix: enable all tests --- .github/workflows/test_common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 15b46fe492..f6e1b5ffc2 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -49,7 +49,7 @@ jobs: - run: pip install -r requirements.txt - name: Run tests - run: pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + run: pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() From efaf22aa7f1106fe60410ef8d14f9352e62274ac Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 19:28:24 +0800 Subject: [PATCH 063/139] test: problems with current workdir --- .github/workflows/test_common.yml | 4 +++- src/node/waku_node.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index f6e1b5ffc2..20a68c28b9 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -49,7 +49,9 @@ jobs: - run: pip install -r requirements.txt - name: Run tests - run: pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + run: | + pwd + pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() diff --git a/src/node/waku_node.py b/src/node/waku_node.py index 62d0595b44..94f7ad8f10 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -337,6 +337,8 @@ def parse_rln_credentials(self, default_args, is_registration): current_working_directory = os.getcwd() + logger.debug(f"Current working directory: {current_working_directory}") + if self.is_nwaku(): if is_registration: rln_args.update( From 94e735af91297bdd8e2027e4661a3c48cdfbff70 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 19:57:33 +0800 Subject: [PATCH 064/139] test: rln only --- .github/workflows/test_common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 20a68c28b9..764794c016 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -51,7 +51,7 @@ jobs: - name: Run tests run: | pwd - pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + pytest pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() From 1856d3e824c1600537a43ed350360a4700003933 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 20:03:37 +0800 Subject: [PATCH 065/139] test: correct typo --- .github/workflows/test_common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 764794c016..a4a0eac26b 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -51,7 +51,7 @@ jobs: - name: Run tests run: | pwd - pytest pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() From b92250fd184908dd68d26ee16f45f208c378922a Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 20:26:59 +0800 Subject: [PATCH 066/139] test: re-enable all tests - remove current dir debug --- .github/workflows/test_common.yml | 3 +-- src/node/waku_node.py | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index a4a0eac26b..77f7fb5851 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -50,8 +50,7 @@ jobs: - name: Run tests run: | - pwd - pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() diff --git a/src/node/waku_node.py b/src/node/waku_node.py index 94f7ad8f10..62d0595b44 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -337,8 +337,6 @@ def parse_rln_credentials(self, default_args, is_registration): current_working_directory = os.getcwd() - logger.debug(f"Current working directory: {current_working_directory}") - if self.is_nwaku(): if is_registration: rln_args.update( From 9f2ccf1fa318a8eecf04e8b95a2f975280c47813 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 20:28:25 +0800 Subject: [PATCH 067/139] fix: nwaku additional nodes for nim to nim worklfow --- .github/workflows/nim_waku_daily.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nim_waku_daily.yml b/.github/workflows/nim_waku_daily.yml index 9e237da283..1d83de134e 100644 --- a/.github/workflows/nim_waku_daily.yml +++ b/.github/workflows/nim_waku_daily.yml @@ -16,4 +16,5 @@ jobs: with: node1: "harbor.status.im/wakuorg/nwaku:latest" node2: "harbor.status.im/wakuorg/nwaku:latest" + additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" caller: "nim" From 87676856b021d466ada56305f089b278d83caa14 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 20:49:18 +0800 Subject: [PATCH 068/139] fix: re-able discord notification - delete test workflow --- .github/workflows/nim_waku_daily_test.yml | 21 --------------------- .github/workflows/test_common.yml | 18 +++++++++--------- 2 files changed, 9 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/nim_waku_daily_test.yml diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml deleted file mode 100644 index 89084219cf..0000000000 --- a/.github/workflows/nim_waku_daily_test.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Test Nim -> Nim Waku Interop Tests - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: false - -on: - push: - branches: - - chore-rln-relay-tests - workflow_dispatch: - -jobs: - test-common: - uses: ./.github/workflows/test_common.yml - secrets: inherit - with: - node1: "harbor.status.im/wakuorg/nwaku:latest" - node2: "harbor.status.im/wakuorg/nwaku:latest" - additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" - caller: "nim" diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 77f7fb5851..21e5a757aa 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -101,12 +101,12 @@ jobs: echo EOF } >> $GITHUB_ENV -# - name: Send report to Discord -# uses: rjstone/discord-webhook-notify@v1 -# if: always() && env.CALLER != 'manual' -# with: -# severity: ${{ job.status == 'success' && 'info' || 'error' }} -# username: ${{ github.workflow }} -# description: "## Job Result: ${{ job.status }}" -# details: ${{ env.JOB_SUMMARY }} -# webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} + - name: Send report to Discord + uses: rjstone/discord-webhook-notify@v1 + if: always() && env.CALLER != 'manual' + with: + severity: ${{ job.status == 'success' && 'info' || 'error' }} + username: ${{ github.workflow }} + description: "## Job Result: ${{ job.status }}" + details: ${{ env.JOB_SUMMARY }} + webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} From 50e827cb2163d52e3e293c16a9fdb3e232001e1c Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 12 Apr 2024 13:13:01 +0800 Subject: [PATCH 069/139] fix: add get_multiaddr_with_id step - temporarily use local docker images --- src/env_vars.py | 4 ++-- src/steps/relay.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/env_vars.py b/src/env_vars.py index a588185616..6693029fde 100644 --- a/src/env_vars.py +++ b/src/env_vars.py @@ -14,8 +14,8 @@ def get_env_var(var_name, default=None): # Configuration constants. Need to be upercase to appear in reports -DEFAULT_NWAKU = "harbor.status.im/wakuorg/nwaku:latest" -DEFAULT_GOWAKU = "harbor.status.im/wakuorg/go-waku:latest" +DEFAULT_NWAKU = "wakuorg/nwaku:latest" +DEFAULT_GOWAKU = "wakuorg/go-waku:latest" NODE_1 = get_env_var("NODE_1", DEFAULT_GOWAKU) NODE_2 = get_env_var("NODE_2", DEFAULT_NWAKU) ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_GOWAKU},{DEFAULT_NWAKU}") diff --git a/src/steps/relay.py b/src/steps/relay.py index bacf8aba17..4dda23992a 100644 --- a/src/steps/relay.py +++ b/src/steps/relay.py @@ -47,7 +47,7 @@ def setup_main_relay_nodes(self, request): @pytest.fixture(scope="function") def register_main_rln_relay_nodes(self, request): - logger.debug(f"Registering RLN credentials: {inspect.currentframe().f_code.co_name}") + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") self.node1.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") @@ -60,6 +60,7 @@ def setup_main_rln_relay_nodes(self, request): self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1") self.enr_uri = self.node1.get_enr_uri() + self.multiaddr_with_id = self.node1.get_multiaddr_with_id() self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") self.node2.start( relay="true", discv5_bootstrap_node=self.enr_uri, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2", rln_relay_membership_index="1" From e6d56d1a4ff4b5f2365770616089a833a5976b80 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 15 Apr 2024 15:01:18 +0800 Subject: [PATCH 070/139] fix: discard containers used for RLN registration --- src/steps/relay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/steps/relay.py b/src/steps/relay.py index 4dda23992a..698eb5cdd3 100644 --- a/src/steps/relay.py +++ b/src/steps/relay.py @@ -52,7 +52,6 @@ def register_main_rln_relay_nodes(self, request): self.node1.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") self.node2.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") - self.main_nodes.extend([self.node1, self.node2]) @pytest.fixture(scope="function") def setup_main_rln_relay_nodes(self, request): From e3981ffd9de62cdd06fbe1453c38f1db5c816402 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 15 Apr 2024 15:32:48 +0800 Subject: [PATCH 071/139] fix: switch to use cluster ID 1 for RLN --- src/test_data.py | 2 ++ tests/relay/test_rln.py | 28 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/test_data.py b/src/test_data.py index 3cbb7da193..bf52edd269 100644 --- a/src/test_data.py +++ b/src/test_data.py @@ -148,3 +148,5 @@ {"description": "ISO 8601 timestamp", "value": "2023-12-26T10:58:51", "valid_for": []}, {"description": "Missing", "value": None, "valid_for": ["gowaku"]}, ] + +PUBSUB_TOPICS_RLN = ["/waku/2/rs/1/0"] diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index bab598adff..120d7dfb9b 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -2,23 +2,27 @@ import pytest from src.env_vars import RLN_CREDENTIALS +from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger from src.steps.relay import StepsRelay +from src.test_data import SAMPLE_INPUTS, PUBSUB_TOPICS_RLN logger = get_custom_logger(__name__) -@pytest.mark.usefixtures() +@pytest.mark.usefixtures("register_main_rln_relay_nodes", "setup_main_rln_relay_nodes", "subscribe_main_relay_nodes") class TestRelayRLN(StepsRelay): - def test_register_rln(self): - logger.debug("Running register RLN test for main relay nodes") - key_stores_found = 0 + test_pubsub_topic = PUBSUB_TOPICS_RLN[0] - if RLN_CREDENTIALS is None: - pytest.skip("RLN_CREDENTIALS not set, skipping test") - - for k in range(1, 6): - self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id=f"{k}") - self.check_rln_registration(k) - key_stores_found += 1 - assert key_stores_found == 5, f"Invalid number of RLN keystores found, expected 5 found {key_stores_found}" + def test_publish_valid_payloads_at_slow_pace(self): + failed_payloads = [] + for payload in SAMPLE_INPUTS: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.check_published_message_reaches_relay_peer(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + delay(1) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" From add1b826be9f5a912667ed17f5967413d9f3fe78 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 15 Apr 2024 19:08:17 +0800 Subject: [PATCH 072/139] test: publish at slow and spam rate --- tests/relay/test_rln.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 120d7dfb9b..7d8b86c6f2 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -14,9 +14,9 @@ class TestRelayRLN(StepsRelay): test_pubsub_topic = PUBSUB_TOPICS_RLN[0] - def test_publish_valid_payloads_at_slow_pace(self): + def test_publish_with_valid_payloads_at_slow_rate(self): failed_payloads = [] - for payload in SAMPLE_INPUTS: + for payload in SAMPLE_INPUTS[:5]: logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -26,3 +26,15 @@ def test_publish_valid_payloads_at_slow_pace(self): failed_payloads.append(payload["description"]) delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + def test_publish_with_valid_payloads_at_spam_rate(self): + for i, payload in enumerate(SAMPLE_INPUTS[:3]): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.check_published_message_reaches_relay_peer(message) + if i > 1: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + assert "RLN validation failed" in str(e) From 241397ba168be5dd7f5bacac31073b22f540a4f9 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 15 Apr 2024 19:45:26 +0800 Subject: [PATCH 073/139] fix: shorten test data set --- tests/relay/test_rln.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 7d8b86c6f2..e0e71c5b8d 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -28,13 +28,12 @@ def test_publish_with_valid_payloads_at_slow_rate(self): assert not failed_payloads, f"Payloads failed: {failed_payloads}" def test_publish_with_valid_payloads_at_spam_rate(self): - for i, payload in enumerate(SAMPLE_INPUTS[:3]): + for i, payload in enumerate(SAMPLE_INPUTS[:2]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: self.check_published_message_reaches_relay_peer(message) - if i > 1: + if i > 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") except Exception as e: - logger.error(f'Payload {payload["description"]} failed: {str(e)}') assert "RLN validation failed" in str(e) From 2175c7744892d5b6c918352bbb7945bc63cb60ea Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 16 Apr 2024 14:47:50 +0800 Subject: [PATCH 074/139] fix: rebase onto master --- src/steps/relay.py | 45 ++----------------------------- src/steps/rln.py | 60 +++++++++++++++++++++++++++++++++++++++++ tests/relay/test_rln.py | 9 +++---- 3 files changed, 65 insertions(+), 49 deletions(-) create mode 100644 src/steps/rln.py diff --git a/src/steps/relay.py b/src/steps/relay.py index 698eb5cdd3..f61fe6b704 100644 --- a/src/steps/relay.py +++ b/src/steps/relay.py @@ -1,20 +1,17 @@ import inspect -import os from src.libs.custom_logger import get_custom_logger from time import time import pytest import allure -from src.libs.common import to_base64, delay, gen_step_id +from src.libs.common import to_base64, delay from src.node.waku_message import WakuMessage from src.env_vars import ( NODE_1, NODE_2, ADDITIONAL_NODES, NODEKEY, - DEFAULT_NWAKU, - RLN_CREDENTIALS, ) -from src.node.waku_node import WakuNode, rln_credential_store_ready +from src.node.waku_node import WakuNode from tenacity import retry, stop_after_delay, wait_fixed from src.steps.common import StepsCommon from src.test_data import VALID_PUBSUB_TOPICS @@ -45,28 +42,6 @@ def setup_main_relay_nodes(self, request): self.add_node_peer(self.node2, [self.multiaddr_with_id]) self.main_nodes.extend([self.node1, self.node2]) - @pytest.fixture(scope="function") - def register_main_rln_relay_nodes(self, request): - logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") - self.node1.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") - self.node2.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") - - @pytest.fixture(scope="function") - def setup_main_rln_relay_nodes(self, request): - logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") - self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1") - self.enr_uri = self.node1.get_enr_uri() - self.multiaddr_with_id = self.node1.get_multiaddr_with_id() - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") - self.node2.start( - relay="true", discv5_bootstrap_node=self.enr_uri, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2", rln_relay_membership_index="1" - ) - self.add_node_peer(self.node2, [self.multiaddr_with_id]) - self.main_nodes.extend([self.node1, self.node2]) - @pytest.fixture(scope="function") def setup_optional_relay_nodes(self, request): logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") @@ -156,19 +131,3 @@ def delete_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): def subscribe_and_publish_with_retry(self, node_list, pubsub_topic_list): self.ensure_relay_subscriptions_on_nodes(node_list, pubsub_topic_list) self.check_published_message_reaches_relay_peer() - - @allure.step - def register_rln_single_node(self, **kwargs): - logger.debug("Registering RLN credentials for single node") - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{gen_step_id()}") - self.node1.register_rln(rln_creds_source=kwargs["rln_creds_source"], rln_creds_id=kwargs["rln_creds_id"]) - - @allure.step - def check_rln_registration(self, key_id): - current_working_directory = os.getcwd() - creds_file_path = f"{current_working_directory}/keystore_{key_id}/keystore.json" - try: - rln_credential_store_ready(creds_file_path) - except Exception as ex: - logger.error(f"Credentials at {creds_file_path} not available: {ex}") - raise diff --git a/src/steps/rln.py b/src/steps/rln.py new file mode 100644 index 0000000000..9b971d1e70 --- /dev/null +++ b/src/steps/rln.py @@ -0,0 +1,60 @@ +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY +from src.libs.common import gen_step_id +from src.libs.custom_logger import get_custom_logger +import os +import inspect +import pytest +import allure +from src.node.waku_node import WakuNode, rln_credential_store_ready +from tenacity import retry, stop_after_delay, wait_fixed +from src.test_data import PUBSUB_TOPICS_RLN + +logger = get_custom_logger(__name__) + + +class StepsRLN: + test_pubsub_topic = PUBSUB_TOPICS_RLN[0] + test_content_topic = "/test/1/waku-rln-relay/proto" + test_payload = "RLN relay works!!" + + main_nodes = [] + optional_nodes = [] + + @pytest.fixture(scope="function") + def register_main_rln_relay_nodes(self, request): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") + self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") + self.node1.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") + self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") + self.node2.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") + + @pytest.fixture(scope="function") + def setup_main_rln_relay_nodes(self, request): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") + self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") + self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1") + self.enr_uri = self.node1.get_enr_uri() + self.multiaddr_with_id = self.node1.get_multiaddr_with_id() + self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") + self.node2.start( + relay="true", discv5_bootstrap_node=self.enr_uri, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2", rln_relay_membership_index="1" + ) + if self.node2.is_nwaku(): + self.node2.add_peers([self.multiaddr_with_id]) + self.main_nodes.extend([self.node1, self.node2]) + + @allure.step + def register_rln_single_node(self, **kwargs): + logger.debug("Registering RLN credentials for single node") + self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{gen_step_id()}") + self.node1.register_rln(rln_creds_source=kwargs["rln_creds_source"], rln_creds_id=kwargs["rln_creds_id"]) + + @allure.step + def check_rln_registration(self, key_id): + current_working_directory = os.getcwd() + creds_file_path = f"{current_working_directory}/keystore_{key_id}/keystore.json" + try: + rln_credential_store_ready(creds_file_path) + except Exception as ex: + logger.error(f"Credentials at {creds_file_path} not available: {ex}") + raise diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index e0e71c5b8d..d183f96047 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -1,19 +1,16 @@ -import os import pytest -from src.env_vars import RLN_CREDENTIALS from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger from src.steps.relay import StepsRelay -from src.test_data import SAMPLE_INPUTS, PUBSUB_TOPICS_RLN +from src.steps.rln import StepsRLN +from src.test_data import SAMPLE_INPUTS logger = get_custom_logger(__name__) @pytest.mark.usefixtures("register_main_rln_relay_nodes", "setup_main_rln_relay_nodes", "subscribe_main_relay_nodes") -class TestRelayRLN(StepsRelay): - test_pubsub_topic = PUBSUB_TOPICS_RLN[0] - +class TestRelayRLN(StepsRLN, StepsRelay): def test_publish_with_valid_payloads_at_slow_rate(self): failed_payloads = [] for payload in SAMPLE_INPUTS[:5]: From ab37b02d78dc405f7c91543b5cf9dc55c4746a92 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 17 Apr 2024 22:20:39 +0800 Subject: [PATCH 075/139] fix: use send only publish function - add spam and alternate rate tests --- src/steps/rln.py | 22 +++++++++++++++++++--- tests/relay/test_rln.py | 33 +++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 9b971d1e70..27e2b59496 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -1,12 +1,12 @@ from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY -from src.libs.common import gen_step_id +from src.libs.common import gen_step_id, to_base64 from src.libs.custom_logger import get_custom_logger import os import inspect import pytest import allure +from time import time from src.node.waku_node import WakuNode, rln_credential_store_ready -from tenacity import retry, stop_after_delay, wait_fixed from src.test_data import PUBSUB_TOPICS_RLN logger = get_custom_logger(__name__) @@ -16,7 +16,7 @@ class StepsRLN: test_pubsub_topic = PUBSUB_TOPICS_RLN[0] test_content_topic = "/test/1/waku-rln-relay/proto" test_payload = "RLN relay works!!" - + epoch_time = 1 # seconds main_nodes = [] optional_nodes = [] @@ -58,3 +58,19 @@ def check_rln_registration(self, key_id): except Exception as ex: logger.error(f"Credentials at {creds_file_path} not available: {ex}") raise + + @allure.step + def create_message(self, **kwargs): + message = {"payload": to_base64(self.test_payload), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)} + message.update(kwargs) + return message + + def publish_message(self, message=None, pubsub_topic=None, sender=None): + if message is None: + message = self.create_message() + if pubsub_topic is None: + pubsub_topic = self.test_pubsub_topic + if not sender: + sender = self.node1 + + sender.send_relay_message(message, pubsub_topic) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index d183f96047..9d02cd6ad1 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -1,3 +1,6 @@ +import math +from time import time + import pytest from src.libs.common import delay, to_base64 @@ -17,7 +20,7 @@ def test_publish_with_valid_payloads_at_slow_rate(self): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - self.check_published_message_reaches_relay_peer(message) + self.publish_message(message) except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) @@ -25,12 +28,34 @@ def test_publish_with_valid_payloads_at_slow_rate(self): assert not failed_payloads, f"Payloads failed: {failed_payloads}" def test_publish_with_valid_payloads_at_spam_rate(self): - for i, payload in enumerate(SAMPLE_INPUTS[:2]): + previous = int(time()) + for i, payload in enumerate(SAMPLE_INPUTS[:4]): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + now = int(time()) + self.publish_message(message) + if i > 0 and (now - previous) == 0: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now + except Exception as e: + assert "RLN validation failed" in str(e) + + def test_publish_with_valid_payloads_at_alternate_rate(self): + previous = math.trunc(time()) + for i, payload in enumerate(SAMPLE_INPUTS): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - self.check_published_message_reaches_relay_peer(message) - if i > 0: + if (i + 1) % 2 == 1: # every odd sample should be sent slowly + delay(1) + now = math.trunc(time()) + logger.debug(f"Message sent at timestamp {now}") + self.publish_message(message) + if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now except Exception as e: assert "RLN validation failed" in str(e) From 0676a49f5a460a2137b1513907b8a52582556047 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 17 Apr 2024 22:58:58 +0800 Subject: [PATCH 076/139] fix: use math.trunc instead of rounding --- tests/relay/test_rln.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 9d02cd6ad1..71ab468a2d 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -24,16 +24,16 @@ def test_publish_with_valid_payloads_at_slow_rate(self): except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) - delay(1) + delay(self.epoch_time) assert not failed_payloads, f"Payloads failed: {failed_payloads}" def test_publish_with_valid_payloads_at_spam_rate(self): - previous = int(time()) + previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS[:4]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - now = int(time()) + now = math.trunc(time()) self.publish_message(message) if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") @@ -42,16 +42,16 @@ def test_publish_with_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - def test_publish_with_valid_payloads_at_alternate_rate(self): + def test_publish_with_valid_payloads_at_variable_rate(self): previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: if (i + 1) % 2 == 1: # every odd sample should be sent slowly - delay(1) + delay(self.epoch_time) now = math.trunc(time()) - logger.debug(f"Message sent at timestamp {now}") + # logger.debug(f"Message sent at timestamp {now}") self.publish_message(message) if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") From 8229e63839ca40aae01409896a5f2c50922bd605 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 17 Apr 2024 23:23:05 +0800 Subject: [PATCH 077/139] fix: first message without delay --- tests/relay/test_rln.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 71ab468a2d..08ebd1d05f 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -48,10 +48,10 @@ def test_publish_with_valid_payloads_at_variable_rate(self): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - if (i + 1) % 2 == 1: # every odd sample should be sent slowly + if i % 2 == 1: # every sample with odd index is sent slowly delay(self.epoch_time) now = math.trunc(time()) - # logger.debug(f"Message sent at timestamp {now}") + logger.debug(f"Message sent at timestamp {now}") self.publish_message(message) if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") From b720ba78113209259bcb9a2ec705ba63f1da3c84 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 17 Apr 2024 23:29:59 +0800 Subject: [PATCH 078/139] fix: add one more second to messages with delay --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 08ebd1d05f..e41a56b806 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -49,7 +49,7 @@ def test_publish_with_valid_payloads_at_variable_rate(self): message = self.create_message(payload=to_base64(payload["value"])) try: if i % 2 == 1: # every sample with odd index is sent slowly - delay(self.epoch_time) + delay(self.epoch_time + 1) now = math.trunc(time()) logger.debug(f"Message sent at timestamp {now}") self.publish_message(message) From 06bd93569028865b26913a8c761e0b0344108571 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 18 Apr 2024 16:10:44 +0800 Subject: [PATCH 079/139] fix: add methods to setup non default RLN nodes --- src/steps/rln.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 27e2b59496..d757404a11 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -1,4 +1,4 @@ -from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY, NODE_1, NODE_2 from src.libs.common import gen_step_id, to_base64 from src.libs.custom_logger import get_custom_logger import os @@ -16,7 +16,7 @@ class StepsRLN: test_pubsub_topic = PUBSUB_TOPICS_RLN[0] test_content_topic = "/test/1/waku-rln-relay/proto" test_payload = "RLN relay works!!" - epoch_time = 1 # seconds + main_nodes = [] optional_nodes = [] @@ -43,6 +43,29 @@ def setup_main_rln_relay_nodes(self, request): self.node2.add_peers([self.multiaddr_with_id]) self.main_nodes.extend([self.node1, self.node2]) + @allure.step + def setup_first_non_default_rln_relay_node(self, **kwargs): + self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") + self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1", **kwargs) + self.enr_uri = self.node1.get_enr_uri() + self.multiaddr_with_id = self.node1.get_multiaddr_with_id() + self.main_nodes.extend([self.node1]) + + @allure.step + def setup_second_non_default_rln_relay_node(self, **kwargs): + self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") + self.node2.start( + relay="true", + discv5_bootstrap_node=self.enr_uri, + rln_creds_source=RLN_CREDENTIALS, + rln_creds_id="2", + rln_relay_membership_index="1", + **kwargs, + ) + if self.node2.is_nwaku(): + self.node2.add_peers([self.multiaddr_with_id]) + self.main_nodes.extend([self.node2]) + @allure.step def register_rln_single_node(self, **kwargs): logger.debug("Registering RLN credentials for single node") @@ -65,6 +88,7 @@ def create_message(self, **kwargs): message.update(kwargs) return message + @allure.step def publish_message(self, message=None, pubsub_topic=None, sender=None): if message is None: message = self.create_message() From 43f36c8da7ac29d724679a5447dfe15f7d2be2eb Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 18 Apr 2024 19:21:50 +0800 Subject: [PATCH 080/139] fix: rewrite tests using steps rather than fixtures - prepare for non default settings for RLN --- src/steps/rln.py | 14 ++++++++++++-- tests/relay/test_rln.py | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index d757404a11..d201748900 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -44,7 +44,7 @@ def setup_main_rln_relay_nodes(self, request): self.main_nodes.extend([self.node1, self.node2]) @allure.step - def setup_first_non_default_rln_relay_node(self, **kwargs): + def setup_first_rln_relay_node(self, **kwargs): self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1", **kwargs) self.enr_uri = self.node1.get_enr_uri() @@ -52,7 +52,7 @@ def setup_first_non_default_rln_relay_node(self, **kwargs): self.main_nodes.extend([self.node1]) @allure.step - def setup_second_non_default_rln_relay_node(self, **kwargs): + def setup_second_rln_relay_node(self, **kwargs): self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") self.node2.start( relay="true", @@ -98,3 +98,13 @@ def publish_message(self, message=None, pubsub_topic=None, sender=None): sender = self.node1 sender.send_relay_message(message, pubsub_topic) + + @allure.step + def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): + for node in node_list: + node.set_relay_subscriptions(pubsub_topic_list) + + @allure.step + def subscribe_main_relay_nodes(self): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") + self.ensure_relay_subscriptions_on_nodes(self.main_nodes, [self.test_pubsub_topic]) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index e41a56b806..d48fcd6942 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -12,9 +12,12 @@ logger = get_custom_logger(__name__) -@pytest.mark.usefixtures("register_main_rln_relay_nodes", "setup_main_rln_relay_nodes", "subscribe_main_relay_nodes") +@pytest.mark.usefixtures("register_main_rln_relay_nodes") class TestRelayRLN(StepsRLN, StepsRelay): def test_publish_with_valid_payloads_at_slow_rate(self): + self.setup_first_rln_relay_node() + self.setup_second_rln_relay_node() + self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS[:5]: logger.debug(f'Running test with payload {payload["description"]}') @@ -24,10 +27,13 @@ def test_publish_with_valid_payloads_at_slow_rate(self): except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) - delay(self.epoch_time) + delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" def test_publish_with_valid_payloads_at_spam_rate(self): + self.setup_first_rln_relay_node() + self.setup_second_rln_relay_node() + self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS[:4]): logger.debug(f'Running test with payload {payload["description"]}') @@ -43,13 +49,16 @@ def test_publish_with_valid_payloads_at_spam_rate(self): assert "RLN validation failed" in str(e) def test_publish_with_valid_payloads_at_variable_rate(self): + self.setup_first_rln_relay_node() + self.setup_second_rln_relay_node() + self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: if i % 2 == 1: # every sample with odd index is sent slowly - delay(self.epoch_time + 1) + delay(1 + 1) now = math.trunc(time()) logger.debug(f"Message sent at timestamp {now}") self.publish_message(message) From 5e927b85500610db90c738b849683907aa1af7ad Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 18 Apr 2024 19:35:02 +0800 Subject: [PATCH 081/139] test: random epoch with valid_payloads_at_slow_rate --- tests/relay/test_rln.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index d48fcd6942..7467772af0 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -1,4 +1,5 @@ import math +import random from time import time import pytest @@ -68,3 +69,20 @@ def test_publish_with_valid_payloads_at_variable_rate(self): previous = now except Exception as e: assert "RLN validation failed" in str(e) + + def test_publish_with_valid_payloads_at_slow_rate_rand_epoch(self): + epoch_sec = random.randint(2, 5) + self.setup_first_rln_relay_node(rln_relay_epoch_sec=epoch_sec) + self.setup_second_rln_relay_node(rln_relay_epoch_sec=epoch_sec) + self.subscribe_main_relay_nodes() + failed_payloads = [] + for payload in SAMPLE_INPUTS[:5]: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.publish_message(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + delay(epoch_sec) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" From 38382dd0804066a58d15a89fb27f6b96809fd61c Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 18 Apr 2024 20:18:18 +0800 Subject: [PATCH 082/139] test: random user message limit with valid payloads --- tests/relay/test_rln.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 7467772af0..7334b65544 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -86,3 +86,19 @@ def test_publish_with_valid_payloads_at_slow_rate_rand_epoch(self): failed_payloads.append(payload["description"]) delay(epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + def test_publish_with_valid_payloads_random_user_message_limit(self): + user_message_limit = random.randint(2, 4) + self.setup_first_rln_relay_node(rln_relay_user_message_limit=user_message_limit) + self.setup_second_rln_relay_node(rln_relay_user_message_limit=user_message_limit) + self.subscribe_main_relay_nodes() + failed_payloads = [] + for payload in SAMPLE_INPUTS[:user_message_limit]: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.publish_message(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" From f814a68766acce8210f586ac2c074eb31cb881a1 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 19 Apr 2024 13:23:37 +0800 Subject: [PATCH 083/139] fix: skip test "random user message limit with valid payloads" --- tests/relay/test_rln.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 7334b65544..68262ef272 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -87,6 +87,7 @@ def test_publish_with_valid_payloads_at_slow_rate_rand_epoch(self): delay(epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.skip(reason="waiting for RLN v2 implementation") def test_publish_with_valid_payloads_random_user_message_limit(self): user_message_limit = random.randint(2, 4) self.setup_first_rln_relay_node(rln_relay_user_message_limit=user_message_limit) From 01fae783a1f7b2e5be8feaf675f1389fc19c643a Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 19 Apr 2024 13:29:25 +0800 Subject: [PATCH 084/139] fix: mark flaky "at variable_rate with valid payloads" --- tests/relay/test_rln.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 68262ef272..1ecaa402ed 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -49,6 +49,7 @@ def test_publish_with_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.skip(reason="flaky because of problems with time measurement") def test_publish_with_valid_payloads_at_variable_rate(self): self.setup_first_rln_relay_node() self.setup_second_rln_relay_node() From cca30d5625640a7aac35d7e6d7d833505748468c Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 19 Apr 2024 15:54:46 +0800 Subject: [PATCH 085/139] fix: rename tests for easier debugging --- tests/relay/test_rln.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 1ecaa402ed..653300f3e0 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -71,7 +71,7 @@ def test_publish_with_valid_payloads_at_variable_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - def test_publish_with_valid_payloads_at_slow_rate_rand_epoch(self): + def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): epoch_sec = random.randint(2, 5) self.setup_first_rln_relay_node(rln_relay_epoch_sec=epoch_sec) self.setup_second_rln_relay_node(rln_relay_epoch_sec=epoch_sec) @@ -104,3 +104,19 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): + self.setup_first_rln_relay_node(rln_relay_dynamic="true") + self.setup_second_rln_relay_node(rln_relay_dynamic="true") + self.subscribe_main_relay_nodes() + failed_payloads = [] + for payload in SAMPLE_INPUTS[:5]: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.publish_message(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + delay(1) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" From f699099355b6c5a67cb30237718e5f77684ec055 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 22 Apr 2024 15:45:09 +0800 Subject: [PATCH 086/139] fix: mark valid_payloads_dynamic_at_slow_rate to skip --- src/node/waku_node.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node/waku_node.py b/src/node/waku_node.py index f3d8a773c0..afd864a488 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -113,6 +113,8 @@ def start(self, **kwargs): else: logger.info(f"RLN credentials not set or credential store not available, starting without RLN") + logger.debug(f"Using volumes {self._volumes}") + self._container = self._docker_manager.start_container( self._docker_manager.image, self._ports, default_args, self._log_path, self._ext_ip, self._volumes ) From 027b446202791ceb4a51e71b08c14c9303f3f542 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 22 Apr 2024 15:46:09 +0800 Subject: [PATCH 087/139] fix: forgot to add actual file --- tests/relay/test_rln.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 653300f3e0..39a7a41d7c 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -105,6 +105,7 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.skip(reason="pending on https://github.com/waku-org/nwaku/issues/2606") def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): self.setup_first_rln_relay_node(rln_relay_dynamic="true") self.setup_second_rln_relay_node(rln_relay_dynamic="true") From a034ad6a5b98a7d1ac0e5ee8deb22efed8220aa8 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 13:57:47 +0800 Subject: [PATCH 088/139] test: valid payloads dynamic(on chain) at spam rate - extend timeout for ensure_ready() to 600s - add ensure_healthy() for future use - add text content based rest call - remove NODE1, NODE2 imports --- src/node/api_clients/rest.py | 9 +++++++++ src/node/waku_node.py | 10 +++++++++- src/steps/rln.py | 2 +- tests/relay/test_rln.py | 21 ++++++++++++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/node/api_clients/rest.py b/src/node/api_clients/rest.py index bfb6bea0a4..daaedd0c64 100644 --- a/src/node/api_clients/rest.py +++ b/src/node/api_clients/rest.py @@ -15,10 +15,19 @@ def rest_call(self, method, endpoint, payload=None): headers = {"Content-Type": "application/json"} return self.make_request(method, url, headers=headers, data=payload) + def rest_call_text(self, method, endpoint, payload=None): + url = f"http://127.0.0.1:{self._rest_port}/{endpoint}" + headers = {"accept": "text/plain"} + return self.make_request(method, url, headers=headers, data=payload) + def info(self): info_response = self.rest_call("get", "debug/v1/info") return info_response.json() + def health(self): + health_response = self.rest_call_text("get", "health") + return health_response.text() + def get_peers(self): get_peers_response = self.rest_call("get", "admin/v1/peers") return get_peers_response.json() diff --git a/src/node/waku_node.py b/src/node/waku_node.py index afd864a488..3effa16ee8 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -186,11 +186,16 @@ def unpause(self): logger.debug(f"Unpause container with id {self._container.short_id}") self._container.unpause() - @retry(stop=stop_after_delay(10), wait=wait_fixed(0.1), reraise=True) + @retry(stop=stop_after_delay(600), wait=wait_fixed(1), reraise=True) def ensure_ready(self): self.info_response = self.info() logger.info("REST service is ready !!") + @retry(stop=stop_after_delay(600), wait=wait_fixed(1), reraise=True) + def ensure_healthy(self): + self.health_response = self.health() + logger.info("Node is healthy !!") + def get_enr_uri(self): try: return self.info_response["enrUri"] @@ -210,6 +215,9 @@ def get_multiaddr_with_id(self): def info(self): return self._api.info() + def health(self): + return self._api.health() + def get_peers(self): return self._api.get_peers() diff --git a/src/steps/rln.py b/src/steps/rln.py index d201748900..c48ba704a7 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -1,4 +1,4 @@ -from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY, NODE_1, NODE_2 +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY from src.libs.common import gen_step_id, to_base64 from src.libs.custom_logger import get_custom_logger import os diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 39a7a41d7c..40f3218d2a 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -105,7 +105,7 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="pending on https://github.com/waku-org/nwaku/issues/2606") + @pytest.mark.timeout(600) def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): self.setup_first_rln_relay_node(rln_relay_dynamic="true") self.setup_second_rln_relay_node(rln_relay_dynamic="true") @@ -121,3 +121,22 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): failed_payloads.append(payload["description"]) delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + @pytest.mark.timeout(600) + def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): + self.setup_first_rln_relay_node(rln_relay_dynamic="true") + self.setup_second_rln_relay_node(rln_relay_dynamic="true") + self.subscribe_main_relay_nodes() + previous = math.trunc(time()) + for i, payload in enumerate(SAMPLE_INPUTS[:4]): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + now = math.trunc(time()) + self.publish_message(message) + if i > 0 and (now - previous) == 0: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now + except Exception as e: + assert "RLN validation failed" in str(e) From b67faa91d47bbfef228db623d120fe58fe3f7ad9 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 15:41:53 +0800 Subject: [PATCH 089/139] fix: revert env_vars to source images from Harbor --- src/env_vars.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/env_vars.py b/src/env_vars.py index 6693029fde..a588185616 100644 --- a/src/env_vars.py +++ b/src/env_vars.py @@ -14,8 +14,8 @@ def get_env_var(var_name, default=None): # Configuration constants. Need to be upercase to appear in reports -DEFAULT_NWAKU = "wakuorg/nwaku:latest" -DEFAULT_GOWAKU = "wakuorg/go-waku:latest" +DEFAULT_NWAKU = "harbor.status.im/wakuorg/nwaku:latest" +DEFAULT_GOWAKU = "harbor.status.im/wakuorg/go-waku:latest" NODE_1 = get_env_var("NODE_1", DEFAULT_GOWAKU) NODE_2 = get_env_var("NODE_2", DEFAULT_NWAKU) ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_GOWAKU},{DEFAULT_NWAKU}") From dd17131838c7c793c58d45bf9bf621cec0a0765e Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 17:19:23 +0800 Subject: [PATCH 090/139] fix: reuse setup first and second rln relay node for setup_main_rln_relay_nodes --- src/steps/rln.py | 18 ++++-------------- tests/relay/test_rln.py | 21 +++++++-------------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index c48ba704a7..ffce0def42 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -28,20 +28,10 @@ def register_main_rln_relay_nodes(self, request): self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") self.node2.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") - @pytest.fixture(scope="function") - def setup_main_rln_relay_nodes(self, request): - logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") - self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1") - self.enr_uri = self.node1.get_enr_uri() - self.multiaddr_with_id = self.node1.get_multiaddr_with_id() - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") - self.node2.start( - relay="true", discv5_bootstrap_node=self.enr_uri, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2", rln_relay_membership_index="1" - ) - if self.node2.is_nwaku(): - self.node2.add_peers([self.multiaddr_with_id]) - self.main_nodes.extend([self.node1, self.node2]) + @allure.step + def setup_main_rln_relay_nodes(self, **kwargs): + self.setup_first_rln_relay_node(**kwargs) + self.setup_second_rln_relay_node(**kwargs) @allure.step def setup_first_rln_relay_node(self, **kwargs): diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 40f3218d2a..a5bc593455 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -16,8 +16,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") class TestRelayRLN(StepsRLN, StepsRelay): def test_publish_with_valid_payloads_at_slow_rate(self): - self.setup_first_rln_relay_node() - self.setup_second_rln_relay_node() + self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS[:5]: @@ -32,8 +31,7 @@ def test_publish_with_valid_payloads_at_slow_rate(self): assert not failed_payloads, f"Payloads failed: {failed_payloads}" def test_publish_with_valid_payloads_at_spam_rate(self): - self.setup_first_rln_relay_node() - self.setup_second_rln_relay_node() + self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS[:4]): @@ -51,8 +49,7 @@ def test_publish_with_valid_payloads_at_spam_rate(self): @pytest.mark.skip(reason="flaky because of problems with time measurement") def test_publish_with_valid_payloads_at_variable_rate(self): - self.setup_first_rln_relay_node() - self.setup_second_rln_relay_node() + self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS): @@ -73,8 +70,7 @@ def test_publish_with_valid_payloads_at_variable_rate(self): def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): epoch_sec = random.randint(2, 5) - self.setup_first_rln_relay_node(rln_relay_epoch_sec=epoch_sec) - self.setup_second_rln_relay_node(rln_relay_epoch_sec=epoch_sec) + self.setup_main_rln_relay_nodes(rln_relay_epoch_sec=epoch_sec) self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS[:5]: @@ -91,8 +87,7 @@ def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): @pytest.mark.skip(reason="waiting for RLN v2 implementation") def test_publish_with_valid_payloads_random_user_message_limit(self): user_message_limit = random.randint(2, 4) - self.setup_first_rln_relay_node(rln_relay_user_message_limit=user_message_limit) - self.setup_second_rln_relay_node(rln_relay_user_message_limit=user_message_limit) + self.setup_main_rln_relay_nodes(rln_relay_user_message_limit=user_message_limit) self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS[:user_message_limit]: @@ -107,8 +102,7 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): @pytest.mark.timeout(600) def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): - self.setup_first_rln_relay_node(rln_relay_dynamic="true") - self.setup_second_rln_relay_node(rln_relay_dynamic="true") + self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS[:5]: @@ -124,8 +118,7 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): @pytest.mark.timeout(600) def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): - self.setup_first_rln_relay_node(rln_relay_dynamic="true") - self.setup_second_rln_relay_node(rln_relay_dynamic="true") + self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS[:4]): From 99387d684f0f7925716aa1ec61a746e1cf21c50f Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 19:24:51 +0800 Subject: [PATCH 091/139] fix: reuse register_rln_single_node for register_main_rln_relay_nodes --- src/steps/rln.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index ffce0def42..34a6b2c09a 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -23,10 +23,8 @@ class StepsRLN: @pytest.fixture(scope="function") def register_main_rln_relay_nodes(self, request): logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}") - self.node1.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}") - self.node2.register_rln(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") + self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") + self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") @allure.step def setup_main_rln_relay_nodes(self, **kwargs): From 2a38bae21fe7d9ec006d420d63d19bfd3364bca8 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 19:41:38 +0800 Subject: [PATCH 092/139] fix: start using src.steps.common - removed RLN test class inheritance from StepsRelay --- src/steps/rln.py | 18 ++++++------------ tests/relay/test_rln.py | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 34a6b2c09a..1d250e6607 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -1,18 +1,18 @@ -from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY -from src.libs.common import gen_step_id, to_base64 -from src.libs.custom_logger import get_custom_logger import os import inspect import pytest import allure -from time import time -from src.node.waku_node import WakuNode, rln_credential_store_ready +from src.steps.common import StepsCommon from src.test_data import PUBSUB_TOPICS_RLN +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY +from src.libs.common import gen_step_id +from src.libs.custom_logger import get_custom_logger +from src.node.waku_node import WakuNode, rln_credential_store_ready logger = get_custom_logger(__name__) -class StepsRLN: +class StepsRLN(StepsCommon): test_pubsub_topic = PUBSUB_TOPICS_RLN[0] test_content_topic = "/test/1/waku-rln-relay/proto" test_payload = "RLN relay works!!" @@ -70,12 +70,6 @@ def check_rln_registration(self, key_id): logger.error(f"Credentials at {creds_file_path} not available: {ex}") raise - @allure.step - def create_message(self, **kwargs): - message = {"payload": to_base64(self.test_payload), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)} - message.update(kwargs) - return message - @allure.step def publish_message(self, message=None, pubsub_topic=None, sender=None): if message is None: diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index a5bc593455..2938732e9d 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -14,7 +14,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") -class TestRelayRLN(StepsRLN, StepsRelay): +class TestRelayRLN(StepsRLN): def test_publish_with_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() From 36123ae87eff1fa0edceef70919f22ef3a04856c Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 Apr 2024 19:49:30 +0800 Subject: [PATCH 093/139] fix: test using whole data set at test payloads_at_slow_rate --- tests/relay/test_rln.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 2938732e9d..399ee5bb7f 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -1,12 +1,9 @@ import math import random from time import time - import pytest - from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger -from src.steps.relay import StepsRelay from src.steps.rln import StepsRLN from src.test_data import SAMPLE_INPUTS @@ -19,7 +16,7 @@ def test_publish_with_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() failed_payloads = [] - for payload in SAMPLE_INPUTS[:5]: + for payload in SAMPLE_INPUTS: logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: From 07046b8df489b7beed891ad31bd163818caaa1f7 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 24 Apr 2024 10:47:58 +0800 Subject: [PATCH 094/139] fix: switch to send msg and check for slow rate tests --- src/steps/rln.py | 26 ++++++++++++++++++++++++-- tests/relay/test_rln.py | 6 +++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 1d250e6607..011fad3a55 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -2,10 +2,12 @@ import inspect import pytest import allure + +from src.node.waku_message import WakuMessage from src.steps.common import StepsCommon from src.test_data import PUBSUB_TOPICS_RLN from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY -from src.libs.common import gen_step_id +from src.libs.common import gen_step_id, delay from src.libs.custom_logger import get_custom_logger from src.node.waku_node import WakuNode, rln_credential_store_ready @@ -81,6 +83,27 @@ def publish_message(self, message=None, pubsub_topic=None, sender=None): sender.send_relay_message(message, pubsub_topic) + @allure.step + def check_published_message_reaches_relay_peer(self, message=None, pubsub_topic=None, message_propagation_delay=0.1, sender=None, peer_list=None): + if message is None: + message = self.create_message() + if pubsub_topic is None: + pubsub_topic = self.test_pubsub_topic + if not sender: + sender = self.node1 + if not peer_list: + peer_list = self.main_nodes + self.optional_nodes + + sender.send_relay_message(message, pubsub_topic) + delay(message_propagation_delay) + for index, peer in enumerate(peer_list): + logger.debug(f"Checking that peer NODE_{index + 1}:{peer.image} can find the published message") + get_messages_response = peer.get_relay_messages(pubsub_topic) + assert get_messages_response, f"Peer NODE_{index + 1}:{peer.image} couldn't find any messages" + assert len(get_messages_response) == 1, f"Expected 1 message but got {len(get_messages_response)}" + waku_message = WakuMessage(get_messages_response) + waku_message.assert_received_message(message) + @allure.step def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): for node in node_list: @@ -88,5 +111,4 @@ def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): @allure.step def subscribe_main_relay_nodes(self): - logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") self.ensure_relay_subscriptions_on_nodes(self.main_nodes, [self.test_pubsub_topic]) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 399ee5bb7f..bf71ddd5b5 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -20,7 +20,7 @@ def test_publish_with_valid_payloads_at_slow_rate(self): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - self.publish_message(message) + self.check_published_message_reaches_relay_peer(message) except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) @@ -74,7 +74,7 @@ def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - self.publish_message(message) + self.check_published_message_reaches_relay_peer(message) except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) @@ -106,7 +106,7 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: - self.publish_message(message) + self.check_published_message_reaches_relay_peer(message) except Exception as e: logger.error(f'Payload {payload["description"]} failed: {str(e)}') failed_payloads.append(payload["description"]) From 71db6ba52359c7ae2cd7c54a894506735bdc5c43 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 24 Apr 2024 16:15:15 +0800 Subject: [PATCH 095/139] fix: add comment for skip check at first message --- tests/relay/test_rln.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index bf71ddd5b5..bb51f82e10 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -31,12 +31,13 @@ def test_publish_with_valid_payloads_at_spam_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS[:4]): + for i, payload in enumerate(SAMPLE_INPUTS): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: now = math.trunc(time()) self.publish_message(message) + # Skip for the first message (i > 0) - previous could be too apart from now if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") else: @@ -97,7 +98,7 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.timeout(600) + @pytest.mark.timeout(700) def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() @@ -113,7 +114,7 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.timeout(600) + @pytest.mark.timeout(700) def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() From 18d0bd320998839235f488795dcd440e8e5dcab2 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 24 Apr 2024 16:48:26 +0800 Subject: [PATCH 096/139] fix: refactor payloads_at_variable_rate to use only one payload pattern --- tests/relay/test_rln.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index bb51f82e10..a0299b188c 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -45,16 +45,17 @@ def test_publish_with_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.skip(reason="flaky because of problems with time measurement") def test_publish_with_valid_payloads_at_variable_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() + payload_desc = SAMPLE_INPUTS[0]["description"] + payload = to_base64(SAMPLE_INPUTS[0]["value"]) previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): - logger.debug(f'Running test with payload {payload["description"]}') - message = self.create_message(payload=to_base64(payload["value"])) + for i in range(0, 10): + logger.debug(f"Running test with payload {payload_desc}") + message = self.create_message(payload=payload) try: - if i % 2 == 1: # every sample with odd index is sent slowly + if i % 2 == 1: # every odd iteration is sent slowly delay(1 + 1) now = math.trunc(time()) logger.debug(f"Message sent at timestamp {now}") From 776828c5a39d991928fb50319796de692faa7e96 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 24 Apr 2024 16:50:32 +0800 Subject: [PATCH 097/139] fix: remove the plural from payloads_at_variable_rate --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index a0299b188c..76818410c9 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -45,7 +45,7 @@ def test_publish_with_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - def test_publish_with_valid_payloads_at_variable_rate(self): + def test_publish_with_valid_payload_at_variable_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() payload_desc = SAMPLE_INPUTS[0]["description"] From 285a652da8dfabba98abdb3aeae5f0283371c06b Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 24 Apr 2024 17:13:10 +0800 Subject: [PATCH 098/139] fix: multiple class inheritance for TestRelayRLN --- src/steps/rln.py | 21 --------------------- tests/relay/test_rln.py | 7 ++++--- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 011fad3a55..8062901695 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -83,27 +83,6 @@ def publish_message(self, message=None, pubsub_topic=None, sender=None): sender.send_relay_message(message, pubsub_topic) - @allure.step - def check_published_message_reaches_relay_peer(self, message=None, pubsub_topic=None, message_propagation_delay=0.1, sender=None, peer_list=None): - if message is None: - message = self.create_message() - if pubsub_topic is None: - pubsub_topic = self.test_pubsub_topic - if not sender: - sender = self.node1 - if not peer_list: - peer_list = self.main_nodes + self.optional_nodes - - sender.send_relay_message(message, pubsub_topic) - delay(message_propagation_delay) - for index, peer in enumerate(peer_list): - logger.debug(f"Checking that peer NODE_{index + 1}:{peer.image} can find the published message") - get_messages_response = peer.get_relay_messages(pubsub_topic) - assert get_messages_response, f"Peer NODE_{index + 1}:{peer.image} couldn't find any messages" - assert len(get_messages_response) == 1, f"Expected 1 message but got {len(get_messages_response)}" - waku_message = WakuMessage(get_messages_response) - waku_message.assert_received_message(message) - @allure.step def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): for node in node_list: diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 76818410c9..2cc226c479 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -4,6 +4,7 @@ import pytest from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger +from src.steps.relay import StepsRelay from src.steps.rln import StepsRLN from src.test_data import SAMPLE_INPUTS @@ -11,7 +12,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") -class TestRelayRLN(StepsRLN): +class TestRelayRLN(StepsRLN, StepsRelay): def test_publish_with_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -104,7 +105,7 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() failed_payloads = [] - for payload in SAMPLE_INPUTS[:5]: + for payload in SAMPLE_INPUTS: logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -120,7 +121,7 @@ def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS[:4]): + for i, payload in enumerate(SAMPLE_INPUTS): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: From bab25743a74b4f29f5638dc958ce915deb436f54 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 25 Apr 2024 14:38:11 +0800 Subject: [PATCH 099/139] test: node1 with rln node2 without rln at spam rate --- src/steps/rln.py | 20 ++++++++++++++++++++ tests/relay/test_rln.py | 36 +++++++++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 8062901695..829539cec1 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -56,6 +56,26 @@ def setup_second_rln_relay_node(self, **kwargs): self.node2.add_peers([self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) + @allure.step + def setup_first_relay_node(self, **kwargs): + self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") + self.node1.start(relay="true", nodekey=NODEKEY, **kwargs) + self.enr_uri = self.node1.get_enr_uri() + self.multiaddr_with_id = self.node1.get_multiaddr_with_id() + self.main_nodes.extend([self.node1]) + + @allure.step + def setup_second_relay_node(self, **kwargs): + self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") + self.node2.start( + relay="true", + discv5_bootstrap_node=self.enr_uri, + **kwargs, + ) + if self.node2.is_nwaku(): + self.node2.add_peers([self.multiaddr_with_id]) + self.main_nodes.extend([self.node2]) + @allure.step def register_rln_single_node(self, **kwargs): logger.debug("Registering RLN credentials for single node") diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 2cc226c479..e9832b51e3 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -13,7 +13,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") class TestRelayRLN(StepsRLN, StepsRelay): - def test_publish_with_valid_payloads_at_slow_rate(self): + def test_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() failed_payloads = [] @@ -28,7 +28,7 @@ def test_publish_with_valid_payloads_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - def test_publish_with_valid_payloads_at_spam_rate(self): + def test_valid_payloads_at_spam_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() previous = math.trunc(time()) @@ -46,7 +46,7 @@ def test_publish_with_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - def test_publish_with_valid_payload_at_variable_rate(self): + def test_valid_payload_at_variable_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() payload_desc = SAMPLE_INPUTS[0]["description"] @@ -68,7 +68,7 @@ def test_publish_with_valid_payload_at_variable_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): + def test_valid_payloads_random_epoch_at_slow_rate(self): epoch_sec = random.randint(2, 5) self.setup_main_rln_relay_nodes(rln_relay_epoch_sec=epoch_sec) self.subscribe_main_relay_nodes() @@ -85,7 +85,7 @@ def test_publish_with_valid_payloads_random_epoch_at_slow_rate(self): assert not failed_payloads, f"Payloads failed: {failed_payloads}" @pytest.mark.skip(reason="waiting for RLN v2 implementation") - def test_publish_with_valid_payloads_random_user_message_limit(self): + def test_valid_payloads_random_user_message_limit(self): user_message_limit = random.randint(2, 4) self.setup_main_rln_relay_nodes(rln_relay_user_message_limit=user_message_limit) self.subscribe_main_relay_nodes() @@ -100,8 +100,8 @@ def test_publish_with_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.timeout(700) - def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): + @pytest.mark.timeout(600) + def test_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() failed_payloads = [] @@ -116,8 +116,8 @@ def test_publish_with_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.timeout(700) - def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): + @pytest.mark.timeout(600) + def test_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") self.subscribe_main_relay_nodes() previous = math.trunc(time()) @@ -133,3 +133,21 @@ def test_publish_with_valid_payloads_dynamic_at_spam_rate(self): previous = now except Exception as e: assert "RLN validation failed" in str(e) + + def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): + self.setup_first_rln_relay_node() + self.setup_second_relay_node() + self.subscribe_main_relay_nodes() + previous = math.trunc(time()) + for i, payload in enumerate(SAMPLE_INPUTS): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + now = math.trunc(time()) + self.publish_message(message) + if i > 0 and (now - previous) == 0: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now + except Exception as e: + assert "RLN validation failed" in str(e) From d9d71a68e3d8db42dfc0eba86ecf0ffd0e466144 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 25 Apr 2024 15:04:19 +0800 Subject: [PATCH 100/139] test: mixed epoch at slow rate --- tests/relay/test_rln.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index e9832b51e3..6726b26e17 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -151,3 +151,22 @@ def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): previous = now except Exception as e: assert "RLN validation failed" in str(e) + + @pytest.mark.skip(reason="Peer NODE_2:harbor.status.im/wakuorg/nwaku:latest couldn't find any messages") + def test_valid_payloads_mixed_epoch_at_slow_rate(self): + n1_epoch_sec = 5 + n2_epoch_sec = 1 + self.setup_first_rln_relay_node(rln_relay_epoch_sec=n1_epoch_sec) + self.setup_second_rln_relay_node(rln_relay_epoch_sec=n2_epoch_sec) + self.subscribe_main_relay_nodes() + failed_payloads = [] + for payload in SAMPLE_INPUTS[:5]: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.check_published_message_reaches_relay_peer(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + delay(n1_epoch_sec) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" From e6a138bda185972afd041dd618ac0d7fe1dc7be7 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 25 Apr 2024 22:08:09 +0800 Subject: [PATCH 101/139] test: add lightpush methods --- src/steps/rln.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 829539cec1..84e63492de 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -21,6 +21,8 @@ class StepsRLN(StepsCommon): main_nodes = [] optional_nodes = [] + multiaddr_list = [] + lightpush_nodes = [] @pytest.fixture(scope="function") def register_main_rln_relay_nodes(self, request): @@ -34,9 +36,21 @@ def setup_main_rln_relay_nodes(self, **kwargs): self.setup_second_rln_relay_node(**kwargs) @allure.step - def setup_first_rln_relay_node(self, **kwargs): + def setup_first_rln_relay_node(self, lightpush=None, **kwargs): + node_index = None + if lightpush == "true": + node_index = 1 self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") - self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1", **kwargs) + self.node1.start( + relay="true", + nodekey=NODEKEY, + rln_creds_source=RLN_CREDENTIALS, + rln_creds_id="1", + rln_relay_membership_index="1", + node_index=node_index, + lightpush=lightpush, + **kwargs, + ) self.enr_uri = self.node1.get_enr_uri() self.multiaddr_with_id = self.node1.get_multiaddr_with_id() self.main_nodes.extend([self.node1]) @@ -56,6 +70,15 @@ def setup_second_rln_relay_node(self, **kwargs): self.node2.add_peers([self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) + @allure.step + def setup_lightpush_node(self, relay=None, **kwargs): + self.light_push_node1 = WakuNode(DEFAULT_NWAKU, f"lightpush_node2_{self.test_id}") + self.light_push_node1.start(relay=relay, discv5_bootstrap_node=self.enr_uri, node_index=2, lightpushnode=self.multiaddr_list[0], **kwargs) + if relay == "true": + self.main_nodes.extend([self.light_push_node1]) + self.lightpush_nodes.extend([self.light_push_node1]) + self.add_node_peer(self.light_push_node1, self.multiaddr_list) + @allure.step def setup_first_relay_node(self, **kwargs): self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") @@ -103,6 +126,17 @@ def publish_message(self, message=None, pubsub_topic=None, sender=None): sender.send_relay_message(message, pubsub_topic) + def publish_light_push_message(self, message=None, pubsub_topic=None, sender=None): + if message is None: + message = self.create_message() + if pubsub_topic is None: + pubsub_topic = self.test_pubsub_topic + if not sender: + sender = self.node1 + + payload = self.create_payload(pubsub_topic, message) + sender.send_light_push_message(payload) + @allure.step def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): for node in node_list: @@ -111,3 +145,36 @@ def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): @allure.step def subscribe_main_relay_nodes(self): self.ensure_relay_subscriptions_on_nodes(self.main_nodes, [self.test_pubsub_topic]) + + @allure.step + def create_payload(self, pubsub_topic=None, message=None, **kwargs): + if message is None: + message = self.create_message() + if pubsub_topic is None: + pubsub_topic = self.test_pubsub_topic + payload = {"pubsubTopic": pubsub_topic, "message": message} + payload.update(kwargs) + return payload + + @allure.step + def check_light_pushed_message_reaches_receiving_peer( + self, pubsub_topic=None, message=None, message_propagation_delay=0.1, sender=None, peer_list=None + ): + if pubsub_topic is None: + pubsub_topic = self.test_pubsub_topic + if not sender: + sender = self.node1 + if not peer_list: + peer_list = self.main_nodes + self.optional_nodes + + payload = self.create_payload(pubsub_topic, message) + logger.debug("Lightpushing message") + sender.send_light_push_message(payload) + delay(message_propagation_delay) + for index, peer in enumerate(peer_list): + logger.debug(f"Checking that peer NODE_{index + 1}:{peer.image} can find the lightpushed message") + get_messages_response = peer.get_relay_messages(pubsub_topic) + assert get_messages_response, f"Peer NODE_{index + 1}:{peer.image} couldn't find any messages" + assert len(get_messages_response) == 1, f"Expected 1 message but got {len(get_messages_response)}" + waku_message = WakuMessage(get_messages_response) + waku_message.assert_received_message(payload["message"]) From 3386afae69cd6dd6254632fe78859103ce713614 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 25 Apr 2024 22:12:32 +0800 Subject: [PATCH 102/139] test: send valid payloads lightpush at spam rate --- tests/relay/test_rln.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 6726b26e17..3fe9de423b 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -170,3 +170,22 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): failed_payloads.append(payload["description"]) delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + @pytest.mark.skip(reason="Cannot start RLN relay with lightpush enabled") + def test_valid_payloads_lightpush_at_spam_rate(self): + self.setup_first_rln_relay_node(lightpush="true") # with lightpush enabled + self.setup_lightpush_node() + self.subscribe_main_relay_nodes() + previous = math.trunc(time()) + for i, payload in enumerate(SAMPLE_INPUTS): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + now = math.trunc(time()) + self.publish_light_push_message(message=message, sender=self.light_push_node1) + if i > 0 and (now - previous) == 0: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now + except Exception as e: + assert "RLN validation failed" in str(e) From 475588e13b1778621565798cf3606157fd5167f4 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 13:30:53 +0800 Subject: [PATCH 103/139] fix: node1 to act as light push receiving node - add setup lightpush node to spin off node2 with lightpush support --- src/steps/rln.py | 26 ++++++++++++-------------- tests/relay/test_rln.py | 8 ++++---- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 84e63492de..a6b5a1b942 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -37,9 +37,6 @@ def setup_main_rln_relay_nodes(self, **kwargs): @allure.step def setup_first_rln_relay_node(self, lightpush=None, **kwargs): - node_index = None - if lightpush == "true": - node_index = 1 self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") self.node1.start( relay="true", @@ -47,7 +44,6 @@ def setup_first_rln_relay_node(self, lightpush=None, **kwargs): rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1", - node_index=node_index, lightpush=lightpush, **kwargs, ) @@ -55,6 +51,9 @@ def setup_first_rln_relay_node(self, lightpush=None, **kwargs): self.multiaddr_with_id = self.node1.get_multiaddr_with_id() self.main_nodes.extend([self.node1]) + self.add_node_peer(self.node1, self.multiaddr_list) + self.multiaddr_list.extend([self.node1.get_multiaddr_with_id()]) + @allure.step def setup_second_rln_relay_node(self, **kwargs): self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") @@ -66,18 +65,18 @@ def setup_second_rln_relay_node(self, **kwargs): rln_relay_membership_index="1", **kwargs, ) - if self.node2.is_nwaku(): - self.node2.add_peers([self.multiaddr_with_id]) + + self.add_node_peer(self.node2, [self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) @allure.step - def setup_lightpush_node(self, relay=None, **kwargs): - self.light_push_node1 = WakuNode(DEFAULT_NWAKU, f"lightpush_node2_{self.test_id}") - self.light_push_node1.start(relay=relay, discv5_bootstrap_node=self.enr_uri, node_index=2, lightpushnode=self.multiaddr_list[0], **kwargs) + def setup_second_lightpush_node(self, relay="false", **kwargs): + self.light_push_node2 = WakuNode(DEFAULT_NWAKU, f"lightpush_node2_{self.test_id}") + self.light_push_node2.start(relay=relay, discv5_bootstrap_node=self.enr_uri, lightpush="true", lightpushnode=self.multiaddr_list[0], **kwargs) if relay == "true": - self.main_nodes.extend([self.light_push_node1]) - self.lightpush_nodes.extend([self.light_push_node1]) - self.add_node_peer(self.light_push_node1, self.multiaddr_list) + self.main_nodes.extend([self.light_push_node2]) + self.lightpush_nodes.extend([self.light_push_node2]) + self.add_node_peer(self.light_push_node2, self.multiaddr_list) @allure.step def setup_first_relay_node(self, **kwargs): @@ -95,8 +94,7 @@ def setup_second_relay_node(self, **kwargs): discv5_bootstrap_node=self.enr_uri, **kwargs, ) - if self.node2.is_nwaku(): - self.node2.add_peers([self.multiaddr_with_id]) + self.add_node_peer(self.node2, [self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) @allure.step diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 3fe9de423b..7652c0b146 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -171,10 +171,10 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="Cannot start RLN relay with lightpush enabled") + @pytest.mark.skip(reason="Lightpush node is not adding RLN proofs yet - TBT with Gowaku") def test_valid_payloads_lightpush_at_spam_rate(self): - self.setup_first_rln_relay_node(lightpush="true") # with lightpush enabled - self.setup_lightpush_node() + self.setup_first_rln_relay_node(lightpush="true") + self.setup_second_lightpush_node() self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS): @@ -182,7 +182,7 @@ def test_valid_payloads_lightpush_at_spam_rate(self): message = self.create_message(payload=to_base64(payload["value"])) try: now = math.trunc(time()) - self.publish_light_push_message(message=message, sender=self.light_push_node1) + self.publish_light_push_message(message=message, sender=self.light_push_node2) if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") else: From 44b404bca2ebf6b155daf07a5b975ea01b8f3216 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 15:32:09 +0800 Subject: [PATCH 104/139] fix: use NODE1 NODE2 instead of DEFAULT_NWAKU --- src/steps/rln.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index a6b5a1b942..5ce3838c78 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -6,7 +6,7 @@ from src.node.waku_message import WakuMessage from src.steps.common import StepsCommon from src.test_data import PUBSUB_TOPICS_RLN -from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY, NODE_1, NODE_2 from src.libs.common import gen_step_id, delay from src.libs.custom_logger import get_custom_logger from src.node.waku_node import WakuNode, rln_credential_store_ready @@ -37,7 +37,7 @@ def setup_main_rln_relay_nodes(self, **kwargs): @allure.step def setup_first_rln_relay_node(self, lightpush=None, **kwargs): - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") + self.node1 = WakuNode(NODE_1, f"node1_{self.test_id}") self.node1.start( relay="true", nodekey=NODEKEY, @@ -56,7 +56,7 @@ def setup_first_rln_relay_node(self, lightpush=None, **kwargs): @allure.step def setup_second_rln_relay_node(self, **kwargs): - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") + self.node2 = WakuNode(NODE_2, f"node2_{self.test_id}") self.node2.start( relay="true", discv5_bootstrap_node=self.enr_uri, @@ -71,7 +71,7 @@ def setup_second_rln_relay_node(self, **kwargs): @allure.step def setup_second_lightpush_node(self, relay="false", **kwargs): - self.light_push_node2 = WakuNode(DEFAULT_NWAKU, f"lightpush_node2_{self.test_id}") + self.light_push_node2 = WakuNode(NODE_2, f"lightpush_node2_{self.test_id}") self.light_push_node2.start(relay=relay, discv5_bootstrap_node=self.enr_uri, lightpush="true", lightpushnode=self.multiaddr_list[0], **kwargs) if relay == "true": self.main_nodes.extend([self.light_push_node2]) @@ -80,7 +80,7 @@ def setup_second_lightpush_node(self, relay="false", **kwargs): @allure.step def setup_first_relay_node(self, **kwargs): - self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{self.test_id}") + self.node1 = WakuNode(NODE_1, f"node1_{self.test_id}") self.node1.start(relay="true", nodekey=NODEKEY, **kwargs) self.enr_uri = self.node1.get_enr_uri() self.multiaddr_with_id = self.node1.get_multiaddr_with_id() @@ -88,7 +88,7 @@ def setup_first_relay_node(self, **kwargs): @allure.step def setup_second_relay_node(self, **kwargs): - self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{self.test_id}") + self.node2 = WakuNode(NODE_2, f"node2_{self.test_id}") self.node2.start( relay="true", discv5_bootstrap_node=self.enr_uri, From 2997132637aeb329c9cf4b9a7a41f82e318828d3 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 16:30:34 +0800 Subject: [PATCH 105/139] fix: no lightpush param required for plain RLN relay --- src/steps/rln.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 5ce3838c78..7f3b4544bc 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -36,7 +36,7 @@ def setup_main_rln_relay_nodes(self, **kwargs): self.setup_second_rln_relay_node(**kwargs) @allure.step - def setup_first_rln_relay_node(self, lightpush=None, **kwargs): + def setup_first_rln_relay_node(self, **kwargs): self.node1 = WakuNode(NODE_1, f"node1_{self.test_id}") self.node1.start( relay="true", @@ -44,14 +44,12 @@ def setup_first_rln_relay_node(self, lightpush=None, **kwargs): rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1", - lightpush=lightpush, **kwargs, ) self.enr_uri = self.node1.get_enr_uri() self.multiaddr_with_id = self.node1.get_multiaddr_with_id() self.main_nodes.extend([self.node1]) - self.add_node_peer(self.node1, self.multiaddr_list) self.multiaddr_list.extend([self.node1.get_multiaddr_with_id()]) @allure.step @@ -65,7 +63,6 @@ def setup_second_rln_relay_node(self, **kwargs): rln_relay_membership_index="1", **kwargs, ) - self.add_node_peer(self.node2, [self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) From 786a79bfd23c249d3b34d283b9634d63fda9861d Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 16:35:31 +0800 Subject: [PATCH 106/139] fix: comment for lightpush --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 7652c0b146..e8c328a085 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -171,7 +171,7 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="Lightpush node is not adding RLN proofs yet - TBT with Gowaku") + @pytest.mark.skip(reason="NWAKU lightpush node not adding RLN proofs yet - TBT with Gowaku") def test_valid_payloads_lightpush_at_spam_rate(self): self.setup_first_rln_relay_node(lightpush="true") self.setup_second_lightpush_node() From 4f0e7f05aeac2a1b687478ba75cdd24c1a7edc0d Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 17:00:48 +0800 Subject: [PATCH 107/139] fix: comment for lightpush - wait for implementation --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index e8c328a085..90657eb470 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -171,7 +171,7 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="NWAKU lightpush node not adding RLN proofs yet - TBT with Gowaku") + @pytest.mark.skip(reason="waiting for NWAKU lightpush + RLN node implementation") def test_valid_payloads_lightpush_at_spam_rate(self): self.setup_first_rln_relay_node(lightpush="true") self.setup_second_lightpush_node() From 056c8e0d2ec9ad100e8bf508385c5856e91ec89e Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 26 Apr 2024 17:07:57 +0800 Subject: [PATCH 108/139] fix: comment on chain tests --- tests/relay/test_rln.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 90657eb470..63797f9a03 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -100,6 +100,7 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") @@ -116,6 +117,7 @@ def test_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") From 8fe18443a03445afe7b2f3aaa8a7e27d71e9f43f Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 29 Apr 2024 11:54:21 +0800 Subject: [PATCH 109/139] fix: add lightpush case to publish_message --- src/steps/rln.py | 19 ++++++------------- tests/relay/test_rln.py | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 7f3b4544bc..51a49ca26e 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -111,7 +111,7 @@ def check_rln_registration(self, key_id): raise @allure.step - def publish_message(self, message=None, pubsub_topic=None, sender=None): + def publish_message(self, message=None, pubsub_topic=None, sender=None, use_lightpush=False): if message is None: message = self.create_message() if pubsub_topic is None: @@ -119,18 +119,11 @@ def publish_message(self, message=None, pubsub_topic=None, sender=None): if not sender: sender = self.node1 - sender.send_relay_message(message, pubsub_topic) - - def publish_light_push_message(self, message=None, pubsub_topic=None, sender=None): - if message is None: - message = self.create_message() - if pubsub_topic is None: - pubsub_topic = self.test_pubsub_topic - if not sender: - sender = self.node1 - - payload = self.create_payload(pubsub_topic, message) - sender.send_light_push_message(payload) + if use_lightpush: + payload = self.create_payload(pubsub_topic, message) + sender.send_light_push_message(payload) + else: + sender.send_relay_message(message, pubsub_topic) @allure.step def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 63797f9a03..3806377f40 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -184,7 +184,7 @@ def test_valid_payloads_lightpush_at_spam_rate(self): message = self.create_message(payload=to_base64(payload["value"])) try: now = math.trunc(time()) - self.publish_light_push_message(message=message, sender=self.light_push_node2) + self.publish_message(message=message, sender=self.light_push_node2, use_lightpush=True) if i > 0 and (now - previous) == 0: raise AssertionError("Publish with RLN enabled at spam rate worked!!!") else: From 17816e30a991562245eaffdba606d7f08de97d5b Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 29 Apr 2024 12:05:12 +0800 Subject: [PATCH 110/139] fix: remove check_light_pushed_message_reaches_receiving_peer from StepsRLN --- src/steps/rln.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 51a49ca26e..01919bfaaa 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -143,26 +143,3 @@ def create_payload(self, pubsub_topic=None, message=None, **kwargs): payload = {"pubsubTopic": pubsub_topic, "message": message} payload.update(kwargs) return payload - - @allure.step - def check_light_pushed_message_reaches_receiving_peer( - self, pubsub_topic=None, message=None, message_propagation_delay=0.1, sender=None, peer_list=None - ): - if pubsub_topic is None: - pubsub_topic = self.test_pubsub_topic - if not sender: - sender = self.node1 - if not peer_list: - peer_list = self.main_nodes + self.optional_nodes - - payload = self.create_payload(pubsub_topic, message) - logger.debug("Lightpushing message") - sender.send_light_push_message(payload) - delay(message_propagation_delay) - for index, peer in enumerate(peer_list): - logger.debug(f"Checking that peer NODE_{index + 1}:{peer.image} can find the lightpushed message") - get_messages_response = peer.get_relay_messages(pubsub_topic) - assert get_messages_response, f"Peer NODE_{index + 1}:{peer.image} couldn't find any messages" - assert len(get_messages_response) == 1, f"Expected 1 message but got {len(get_messages_response)}" - waku_message = WakuMessage(get_messages_response) - waku_message.assert_received_message(payload["message"]) From 48298597d797c8462e761710d34530442a7d9daf Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 09:56:11 +0800 Subject: [PATCH 111/139] fix: change comment for mixed_epoch_at_slow_rate --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 3806377f40..24979f9a1b 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -154,7 +154,7 @@ def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.skip(reason="Peer NODE_2:harbor.status.im/wakuorg/nwaku:latest couldn't find any messages") + @pytest.mark.skip(reason="Epoch settings aren't compatible across nodes") def test_valid_payloads_mixed_epoch_at_slow_rate(self): n1_epoch_sec = 5 n2_epoch_sec = 1 From 5d1b4f54f982f23ea1287a2bf70218f1fbd0a6bc Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 14:14:53 +0800 Subject: [PATCH 112/139] test: happy and common case with 5 nodes --- src/steps/rln.py | 35 ++++++++++++++++++++++++++++++++++- tests/relay/test_rln.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/steps/rln.py b/src/steps/rln.py index 01919bfaaa..17337eb04c 100644 --- a/src/steps/rln.py +++ b/src/steps/rln.py @@ -6,7 +6,7 @@ from src.node.waku_message import WakuMessage from src.steps.common import StepsCommon from src.test_data import PUBSUB_TOPICS_RLN -from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY, NODE_1, NODE_2 +from src.env_vars import DEFAULT_NWAKU, RLN_CREDENTIALS, NODEKEY, NODE_1, NODE_2, ADDITIONAL_NODES from src.libs.common import gen_step_id, delay from src.libs.custom_logger import get_custom_logger from src.node.waku_node import WakuNode, rln_credential_store_ready @@ -30,6 +30,13 @@ def register_main_rln_relay_nodes(self, request): self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1") self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2") + @pytest.fixture(scope="function") + def register_optional_rln_relay_nodes(self, request): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") + self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="3") + self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="4") + self.register_rln_single_node(rln_creds_source=RLN_CREDENTIALS, rln_creds_id="5") + @allure.step def setup_main_rln_relay_nodes(self, **kwargs): self.setup_first_rln_relay_node(**kwargs) @@ -66,6 +73,28 @@ def setup_second_rln_relay_node(self, **kwargs): self.add_node_peer(self.node2, [self.multiaddr_with_id]) self.main_nodes.extend([self.node2]) + @allure.step + def setup_optional_rln_relay_nodes(self, **kwargs): + if ADDITIONAL_NODES: + nodes = [node.strip() for node in ADDITIONAL_NODES.split(",")] + else: + pytest.skip("ADDITIONAL_NODES is empty, cannot run test") + if len(nodes) > 3: + logger.debug("More than 3 nodes are not supported for RLN tests, using first 3") + nodes = nodes[:3] + for index, node in enumerate(nodes): + node = WakuNode(node, f"node{index + 3}_{self.test_id}") + node.start( + relay="true", + discv5_bootstrap_node=self.enr_uri, + rln_creds_source=RLN_CREDENTIALS, + rln_creds_id=f"{index + 3}", + rln_relay_membership_index="1", + **kwargs, + ) + self.add_node_peer(node, [self.multiaddr_with_id]) + self.optional_nodes.append(node) + @allure.step def setup_second_lightpush_node(self, relay="false", **kwargs): self.light_push_node2 = WakuNode(NODE_2, f"lightpush_node2_{self.test_id}") @@ -134,6 +163,10 @@ def ensure_relay_subscriptions_on_nodes(self, node_list, pubsub_topic_list): def subscribe_main_relay_nodes(self): self.ensure_relay_subscriptions_on_nodes(self.main_nodes, [self.test_pubsub_topic]) + @allure.step + def subscribe_optional_relay_nodes(self): + self.ensure_relay_subscriptions_on_nodes(self.optional_nodes, [self.test_pubsub_topic]) + @allure.step def create_payload(self, pubsub_topic=None, message=None, **kwargs): if message is None: diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 24979f9a1b..9fe9b335d5 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -191,3 +191,41 @@ def test_valid_payloads_lightpush_at_spam_rate(self): previous = now except Exception as e: assert "RLN validation failed" in str(e) + + @pytest.mark.usefixtures("register_optional_rln_relay_nodes") + def test_valid_payloads_with_optional_nodes_at_slow_rate(self): + self.setup_main_rln_relay_nodes() + self.setup_optional_rln_relay_nodes() + self.subscribe_main_relay_nodes() + self.subscribe_optional_relay_nodes() + failed_payloads = [] + for payload in SAMPLE_INPUTS: + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + self.check_published_message_reaches_relay_peer(message) + except Exception as e: + logger.error(f'Payload {payload["description"]} failed: {str(e)}') + failed_payloads.append(payload["description"]) + delay(1) + assert not failed_payloads, f"Payloads failed: {failed_payloads}" + + @pytest.mark.usefixtures("register_optional_rln_relay_nodes") + def test_valid_payloads_with_optional_nodes_at_spam_rate(self): + self.setup_main_rln_relay_nodes() + self.setup_optional_rln_relay_nodes() + self.subscribe_main_relay_nodes() + self.subscribe_optional_relay_nodes() + previous = math.trunc(time()) + for i, payload in enumerate(SAMPLE_INPUTS): + logger.debug(f'Running test with payload {payload["description"]}') + message = self.create_message(payload=to_base64(payload["value"])) + try: + now = math.trunc(time()) + self.publish_message(message) + if i > 0 and (now - previous) == 0: + raise AssertionError("Publish with RLN enabled at spam rate worked!!!") + else: + previous = now + except Exception as e: + assert "RLN validation failed" in str(e) From cb6a2b894012d16c8d481e19d902e75e73fe75f1 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 14:17:20 +0800 Subject: [PATCH 113/139] fix: add all required fixtures explicitly --- tests/relay/test_rln.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 9fe9b335d5..48a9420860 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -192,7 +192,7 @@ def test_valid_payloads_lightpush_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.usefixtures("register_optional_rln_relay_nodes") + @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.setup_optional_rln_relay_nodes() @@ -210,7 +210,7 @@ def test_valid_payloads_with_optional_nodes_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.usefixtures("register_optional_rln_relay_nodes") + @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_spam_rate(self): self.setup_main_rln_relay_nodes() self.setup_optional_rln_relay_nodes() From b11826ebd9b3e3b0eb827aa59486fa9b2c590340 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 18:33:17 +0800 Subject: [PATCH 114/139] fix: add timeout param to ensure_ready --- src/node/waku_node.py | 17 ++++++++++------- tests/relay/test_rln.py | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/node/waku_node.py b/src/node/waku_node.py index 3effa16ee8..62d0595b44 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -48,7 +48,7 @@ def __init__(self, docker_image, docker_log_prefix=""): logger.debug(f"WakuNode instance initialized with log path {self._log_path}") @retry(stop=stop_after_delay(5), wait=wait_fixed(0.1), reraise=True) - def start(self, **kwargs): + def start(self, wait_for_node_sec=10, **kwargs): logger.debug("Starting Node...") self._docker_manager.create_network() self._ext_ip = self._docker_manager.generate_random_ext_ip() @@ -123,7 +123,7 @@ def start(self, **kwargs): DS.waku_nodes.append(self) delay(1) # if we fire requests to soon after starting the node will sometimes fail to start correctly try: - self.ensure_ready() + self.ensure_ready(timeout_duration=wait_for_node_sec) except Exception as ex: logger.error(f"REST service did not become ready in time: {ex}") raise @@ -186,12 +186,15 @@ def unpause(self): logger.debug(f"Unpause container with id {self._container.short_id}") self._container.unpause() - @retry(stop=stop_after_delay(600), wait=wait_fixed(1), reraise=True) - def ensure_ready(self): - self.info_response = self.info() - logger.info("REST service is ready !!") + def ensure_ready(self, timeout_duration=10): + @retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(0.1), reraise=True) + def check_ready(node=self): + node.info_response = node.info() + logger.info("REST service is ready !!") - @retry(stop=stop_after_delay(600), wait=wait_fixed(1), reraise=True) + check_ready() + + @retry(stop=stop_after_delay(10), wait=wait_fixed(1), reraise=True) def ensure_healthy(self): self.health_response = self.health() logger.info("Node is healthy !!") diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 48a9420860..e0c4e74806 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -103,7 +103,7 @@ def test_valid_payloads_random_user_message_limit(self): @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): - self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") + self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) self.subscribe_main_relay_nodes() failed_payloads = [] for payload in SAMPLE_INPUTS: @@ -120,7 +120,7 @@ def test_valid_payloads_dynamic_at_slow_rate(self): @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_spam_rate(self): - self.setup_main_rln_relay_nodes(rln_relay_dynamic="true") + self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) self.subscribe_main_relay_nodes() previous = math.trunc(time()) for i, payload in enumerate(SAMPLE_INPUTS): From 8cd290f2139415f017160b5168bd329f4929df25 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 30 Apr 2024 19:57:22 +0800 Subject: [PATCH 115/139] fix: skip RLN tests for go-waku --- tests/relay/test_rln.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index e0c4e74806..c0de411cd8 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -2,6 +2,8 @@ import random from time import time import pytest + +from src.env_vars import NODE_1, NODE_2 from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger from src.steps.relay import StepsRelay @@ -12,6 +14,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") +@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku") class TestRelayRLN(StepsRLN, StepsRelay): def test_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() From b41512621736953479d7bd19a6c5878ad2c7cd90 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 3 May 2024 13:54:28 +0800 Subject: [PATCH 116/139] fix: uncomment skip for debugging --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index c0de411cd8..12421791f5 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -103,7 +103,7 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") + # @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) From f9f6b020e3d2a27d2d4dd1838dbd8187d9ae1cbb Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 3 May 2024 14:23:15 +0800 Subject: [PATCH 117/139] fix: put the skip back --- tests/relay/test_rln.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 12421791f5..c0de411cd8 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -103,7 +103,7 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - # @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") + @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) From 3143d33e388d3bee9646f8b6e849e4523df69bab Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 10:31:09 +0800 Subject: [PATCH 118/139] fix: change comment for on chain tests --- tests/relay/test_rln.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index c0de411cd8..5240b399aa 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -103,7 +103,7 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") + @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) @@ -120,7 +120,7 @@ def test_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.skip(reason="exceeding timeout ATM, need to check with devs") + @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) From e61be7213e4687dfea4e67a1d4529e345ee2689b Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 13:33:12 +0800 Subject: [PATCH 119/139] fix: run RLN tests in serial - add grouping of tests to runner - use smaller dataset for spam rate tests --- .github/workflows/test_common.yml | 2 +- tests/relay/test_rln.py | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 1774d891c5..6863cff44f 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -49,7 +49,7 @@ jobs: - run: pip install -r requirements.txt - name: Run tests - run: pytest -n 4 --reruns 2 --alluredir=allure-results + run: pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 5240b399aa..aecd637a21 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -16,6 +16,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") @pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku") class TestRelayRLN(StepsRLN, StepsRelay): + @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -31,11 +32,12 @@ def test_valid_payloads_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_at_spam_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): + for i, payload in enumerate(SAMPLE_INPUTS[:5]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -49,6 +51,7 @@ def test_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payload_at_variable_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -71,6 +74,7 @@ def test_valid_payload_at_variable_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_random_epoch_at_slow_rate(self): epoch_sec = random.randint(2, 5) self.setup_main_rln_relay_nodes(rln_relay_epoch_sec=epoch_sec) @@ -87,6 +91,7 @@ def test_valid_payloads_random_epoch_at_slow_rate(self): delay(epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="waiting for RLN v2 implementation") def test_valid_payloads_random_user_message_limit(self): user_message_limit = random.randint(2, 4) @@ -103,6 +108,7 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): @@ -120,13 +126,14 @@ def test_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_spam_rate(self): self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600) self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): + for i, payload in enumerate(SAMPLE_INPUTS[:5]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -139,12 +146,13 @@ def test_valid_payloads_dynamic_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): self.setup_first_rln_relay_node() self.setup_second_relay_node() self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): + for i, payload in enumerate(SAMPLE_INPUTS[:5]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -157,6 +165,7 @@ def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="Epoch settings aren't compatible across nodes") def test_valid_payloads_mixed_epoch_at_slow_rate(self): n1_epoch_sec = 5 @@ -176,13 +185,14 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="waiting for NWAKU lightpush + RLN node implementation") def test_valid_payloads_lightpush_at_spam_rate(self): self.setup_first_rln_relay_node(lightpush="true") self.setup_second_lightpush_node() self.subscribe_main_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): + for i, payload in enumerate(SAMPLE_INPUTS[:5]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: @@ -195,6 +205,7 @@ def test_valid_payloads_lightpush_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_slow_rate(self): self.setup_main_rln_relay_nodes() @@ -213,6 +224,7 @@ def test_valid_payloads_with_optional_nodes_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" + @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_spam_rate(self): self.setup_main_rln_relay_nodes() @@ -220,7 +232,7 @@ def test_valid_payloads_with_optional_nodes_at_spam_rate(self): self.subscribe_main_relay_nodes() self.subscribe_optional_relay_nodes() previous = math.trunc(time()) - for i, payload in enumerate(SAMPLE_INPUTS): + for i, payload in enumerate(SAMPLE_INPUTS[:5]): logger.debug(f'Running test with payload {payload["description"]}') message = self.create_message(payload=to_base64(payload["value"])) try: From a6795683ba8672749a0b1d9ba1012574ad2be98c Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 13:41:44 +0800 Subject: [PATCH 120/139] test: Nim to Nim workflow --- .github/workflows/nim_waku_daily_test.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/nim_waku_daily_test.yml diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml new file mode 100644 index 0000000000..e4bf8f9677 --- /dev/null +++ b/.github/workflows/nim_waku_daily_test.yml @@ -0,0 +1,20 @@ +name: Test Nim -> Nim Waku Interop Tests + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: false + +on: + push: + branches: + - chore-rln-relay-tests + workflow_dispatch: + +jobs: + test-common: + uses: ./.github/workflows/test_common.yml + secrets: inherit + with: + node1: "harbor.status.im/wakuorg/nwaku:latest" + node2: "harbor.status.im/wakuorg/nwaku:latest" + caller: "nim" From 7e74f2518aa8cc06b6214d40aa58dcad4423d264 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 14:04:59 +0800 Subject: [PATCH 121/139] test: check also additional nodes for go-waku --- tests/relay/test_rln.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index aecd637a21..1ada793ec0 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -3,7 +3,7 @@ from time import time import pytest -from src.env_vars import NODE_1, NODE_2 +from src.env_vars import NODE_1, NODE_2, ADDITIONAL_NODES from src.libs.common import delay, to_base64 from src.libs.custom_logger import get_custom_logger from src.steps.relay import StepsRelay @@ -14,7 +14,7 @@ @pytest.mark.usefixtures("register_main_rln_relay_nodes") -@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku") +@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2 + ADDITIONAL_NODES), reason="Test works only with nwaku") class TestRelayRLN(StepsRLN, StepsRelay): @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_at_slow_rate(self): From c03335b18ee72817cb46d9cae96435f042dbbdac Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 14:26:45 +0800 Subject: [PATCH 122/139] test: all nodes are nwaku --- .github/workflows/nim_waku_daily_test.yml | 1 + .github/workflows/test_common.yml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml index e4bf8f9677..b182bcce84 100644 --- a/.github/workflows/nim_waku_daily_test.yml +++ b/.github/workflows/nim_waku_daily_test.yml @@ -17,4 +17,5 @@ jobs: with: node1: "harbor.status.im/wakuorg/nwaku:latest" node2: "harbor.status.im/wakuorg/nwaku:latest" + additional_nodes: "harbor.status.im/wakuorg/nwaku:latest","harbor.status.im/wakuorg/nwaku:latest","harbor.status.im/wakuorg/nwaku:latest" caller: "nim" diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 6863cff44f..f6e1b5ffc2 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -100,12 +100,12 @@ jobs: echo EOF } >> $GITHUB_ENV - - name: Send report to Discord - uses: rjstone/discord-webhook-notify@v1 - if: always() && env.CALLER != 'manual' - with: - severity: ${{ job.status == 'success' && 'info' || 'error' }} - username: ${{ github.workflow }} - description: "## Job Result: ${{ job.status }}" - details: ${{ env.JOB_SUMMARY }} - webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} +# - name: Send report to Discord +# uses: rjstone/discord-webhook-notify@v1 +# if: always() && env.CALLER != 'manual' +# with: +# severity: ${{ job.status == 'success' && 'info' || 'error' }} +# username: ${{ github.workflow }} +# description: "## Job Result: ${{ job.status }}" +# details: ${{ env.JOB_SUMMARY }} +# webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} From e93b321ceed18599b6bed911ecbccd1a591a2a3c Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 14:29:40 +0800 Subject: [PATCH 123/139] fix: string quotes --- .github/workflows/nim_waku_daily_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml index b182bcce84..89084219cf 100644 --- a/.github/workflows/nim_waku_daily_test.yml +++ b/.github/workflows/nim_waku_daily_test.yml @@ -17,5 +17,5 @@ jobs: with: node1: "harbor.status.im/wakuorg/nwaku:latest" node2: "harbor.status.im/wakuorg/nwaku:latest" - additional_nodes: "harbor.status.im/wakuorg/nwaku:latest","harbor.status.im/wakuorg/nwaku:latest","harbor.status.im/wakuorg/nwaku:latest" + additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" caller: "nim" From 778acb17c64432db23ba759367f7da55a22893e4 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 15:40:51 +0800 Subject: [PATCH 124/139] fix: remove additional nodes --- .github/workflows/nim_waku_daily_test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml index 89084219cf..e4bf8f9677 100644 --- a/.github/workflows/nim_waku_daily_test.yml +++ b/.github/workflows/nim_waku_daily_test.yml @@ -17,5 +17,4 @@ jobs: with: node1: "harbor.status.im/wakuorg/nwaku:latest" node2: "harbor.status.im/wakuorg/nwaku:latest" - additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" caller: "nim" From 7d312597a5ab697fd13b16351ea0b5ef32a7edd0 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 17:44:13 +0800 Subject: [PATCH 125/139] fix: re-arrange skip conditions --- tests/relay/test_rln.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tests/relay/test_rln.py b/tests/relay/test_rln.py index 1ada793ec0..4cf3897285 100644 --- a/tests/relay/test_rln.py +++ b/tests/relay/test_rln.py @@ -13,10 +13,10 @@ logger = get_custom_logger(__name__) +@pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.usefixtures("register_main_rln_relay_nodes") -@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2 + ADDITIONAL_NODES), reason="Test works only with nwaku") +@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku") class TestRelayRLN(StepsRLN, StepsRelay): - @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_at_slow_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -32,7 +32,6 @@ def test_valid_payloads_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_at_spam_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -51,7 +50,6 @@ def test_valid_payloads_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payload_at_variable_rate(self): self.setup_main_rln_relay_nodes() self.subscribe_main_relay_nodes() @@ -74,7 +72,6 @@ def test_valid_payload_at_variable_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_random_epoch_at_slow_rate(self): epoch_sec = random.randint(2, 5) self.setup_main_rln_relay_nodes(rln_relay_epoch_sec=epoch_sec) @@ -91,7 +88,6 @@ def test_valid_payloads_random_epoch_at_slow_rate(self): delay(epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="waiting for RLN v2 implementation") def test_valid_payloads_random_user_message_limit(self): user_message_limit = random.randint(2, 4) @@ -108,7 +104,6 @@ def test_valid_payloads_random_user_message_limit(self): failed_payloads.append(payload["description"]) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_slow_rate(self): @@ -126,7 +121,6 @@ def test_valid_payloads_dynamic_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release") @pytest.mark.timeout(600) def test_valid_payloads_dynamic_at_spam_rate(self): @@ -146,7 +140,6 @@ def test_valid_payloads_dynamic_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.xdist_group(name="RLN serial tests") def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): self.setup_first_rln_relay_node() self.setup_second_relay_node() @@ -165,7 +158,6 @@ def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="Epoch settings aren't compatible across nodes") def test_valid_payloads_mixed_epoch_at_slow_rate(self): n1_epoch_sec = 5 @@ -185,7 +177,6 @@ def test_valid_payloads_mixed_epoch_at_slow_rate(self): delay(n1_epoch_sec) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") @pytest.mark.skip(reason="waiting for NWAKU lightpush + RLN node implementation") def test_valid_payloads_lightpush_at_spam_rate(self): self.setup_first_rln_relay_node(lightpush="true") @@ -205,7 +196,7 @@ def test_valid_payloads_lightpush_at_spam_rate(self): except Exception as e: assert "RLN validation failed" in str(e) - @pytest.mark.xdist_group(name="RLN serial tests") + @pytest.mark.skipif("go-waku" in ADDITIONAL_NODES, reason="Test works only with nwaku") @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_slow_rate(self): self.setup_main_rln_relay_nodes() @@ -224,7 +215,7 @@ def test_valid_payloads_with_optional_nodes_at_slow_rate(self): delay(1) assert not failed_payloads, f"Payloads failed: {failed_payloads}" - @pytest.mark.xdist_group(name="RLN serial tests") + @pytest.mark.skipif("go-waku" in ADDITIONAL_NODES, reason="Test works only with nwaku") @pytest.mark.usefixtures("register_main_rln_relay_nodes", "register_optional_rln_relay_nodes") def test_valid_payloads_with_optional_nodes_at_spam_rate(self): self.setup_main_rln_relay_nodes() From 90f9332397bf6292e6eb925126205827fa57d824 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 17:44:59 +0800 Subject: [PATCH 126/139] test: RLN only --- .github/workflows/test_common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index f6e1b5ffc2..15b46fe492 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -49,7 +49,7 @@ jobs: - run: pip install -r requirements.txt - name: Run tests - run: pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + run: pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() From 42b5dcf19ee7633116002ae8ee60dfb168758563 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 18:08:36 +0800 Subject: [PATCH 127/139] fix: change default additional nodes to nwaku only --- src/env_vars.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/env_vars.py b/src/env_vars.py index a588185616..4c220b7b43 100644 --- a/src/env_vars.py +++ b/src/env_vars.py @@ -18,7 +18,7 @@ def get_env_var(var_name, default=None): DEFAULT_GOWAKU = "harbor.status.im/wakuorg/go-waku:latest" NODE_1 = get_env_var("NODE_1", DEFAULT_GOWAKU) NODE_2 = get_env_var("NODE_2", DEFAULT_NWAKU) -ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_GOWAKU},{DEFAULT_NWAKU}") +ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_NWAKU},{DEFAULT_NWAKU}") # more nodes need to follow the NODE_X pattern DOCKER_LOG_DIR = get_env_var("DOCKER_LOG_DIR", "./log/docker") NETWORK_NAME = get_env_var("NETWORK_NAME", "waku") From de1452151bf3485c7f12416b2b3d78ad38007066 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 18:30:23 +0800 Subject: [PATCH 128/139] fix: change additional nodes rather at top level workflow --- .github/workflows/nim_waku_daily_test.yml | 1 + src/env_vars.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml index e4bf8f9677..89084219cf 100644 --- a/.github/workflows/nim_waku_daily_test.yml +++ b/.github/workflows/nim_waku_daily_test.yml @@ -17,4 +17,5 @@ jobs: with: node1: "harbor.status.im/wakuorg/nwaku:latest" node2: "harbor.status.im/wakuorg/nwaku:latest" + additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" caller: "nim" diff --git a/src/env_vars.py b/src/env_vars.py index 4c220b7b43..a588185616 100644 --- a/src/env_vars.py +++ b/src/env_vars.py @@ -18,7 +18,7 @@ def get_env_var(var_name, default=None): DEFAULT_GOWAKU = "harbor.status.im/wakuorg/go-waku:latest" NODE_1 = get_env_var("NODE_1", DEFAULT_GOWAKU) NODE_2 = get_env_var("NODE_2", DEFAULT_NWAKU) -ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_NWAKU},{DEFAULT_NWAKU}") +ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NWAKU},{DEFAULT_GOWAKU},{DEFAULT_NWAKU}") # more nodes need to follow the NODE_X pattern DOCKER_LOG_DIR = get_env_var("DOCKER_LOG_DIR", "./log/docker") NETWORK_NAME = get_env_var("NETWORK_NAME", "waku") From 340ea54149764d648da1e6a4ddb587e832548426 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 18:41:34 +0800 Subject: [PATCH 129/139] fix: enable all tests --- .github/workflows/test_common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 15b46fe492..f6e1b5ffc2 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -49,7 +49,7 @@ jobs: - run: pip install -r requirements.txt - name: Run tests - run: pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + run: pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() From 55f6ff2824cd1d5fa7d80825f0d9aba405eb1b32 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 19:28:24 +0800 Subject: [PATCH 130/139] test: problems with current workdir --- .github/workflows/test_common.yml | 4 +++- src/node/waku_node.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index f6e1b5ffc2..20a68c28b9 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -49,7 +49,9 @@ jobs: - run: pip install -r requirements.txt - name: Run tests - run: pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + run: | + pwd + pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() diff --git a/src/node/waku_node.py b/src/node/waku_node.py index 62d0595b44..94f7ad8f10 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -337,6 +337,8 @@ def parse_rln_credentials(self, default_args, is_registration): current_working_directory = os.getcwd() + logger.debug(f"Current working directory: {current_working_directory}") + if self.is_nwaku(): if is_registration: rln_args.update( From 0ca41c4d97fee08c14e1c148a01cfdf473aff156 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 19:57:33 +0800 Subject: [PATCH 131/139] test: rln only --- .github/workflows/test_common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 20a68c28b9..764794c016 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -51,7 +51,7 @@ jobs: - name: Run tests run: | pwd - pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + pytest pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() From eb8a7c698bedb7429f09a8e27ba04b8f42213ebb Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 20:03:37 +0800 Subject: [PATCH 132/139] test: correct typo --- .github/workflows/test_common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 764794c016..a4a0eac26b 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -51,7 +51,7 @@ jobs: - name: Run tests run: | pwd - pytest pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() From 1cad269b0e33ab400514cac1c8e2b8408ff93992 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 20:26:59 +0800 Subject: [PATCH 133/139] test: re-enable all tests - remove current dir debug --- .github/workflows/test_common.yml | 3 +-- src/node/waku_node.py | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index a4a0eac26b..77f7fb5851 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -50,8 +50,7 @@ jobs: - name: Run tests run: | - pwd - pytest tests/relay/test_rln.py -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results + pytest -n 4 --dist loadgroup --reruns 2 --alluredir=allure-results - name: Get allure history if: always() diff --git a/src/node/waku_node.py b/src/node/waku_node.py index 94f7ad8f10..62d0595b44 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -337,8 +337,6 @@ def parse_rln_credentials(self, default_args, is_registration): current_working_directory = os.getcwd() - logger.debug(f"Current working directory: {current_working_directory}") - if self.is_nwaku(): if is_registration: rln_args.update( From 67fb3b9067704f27d23f63f48ff66f737fca77a8 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 20:28:25 +0800 Subject: [PATCH 134/139] fix: nwaku additional nodes for nim to nim worklfow --- .github/workflows/nim_waku_daily.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nim_waku_daily.yml b/.github/workflows/nim_waku_daily.yml index 9e237da283..1d83de134e 100644 --- a/.github/workflows/nim_waku_daily.yml +++ b/.github/workflows/nim_waku_daily.yml @@ -16,4 +16,5 @@ jobs: with: node1: "harbor.status.im/wakuorg/nwaku:latest" node2: "harbor.status.im/wakuorg/nwaku:latest" + additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" caller: "nim" From a73dec0d2ea9eaeb92e42908e3bf99d2e13ea74b Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 20:49:18 +0800 Subject: [PATCH 135/139] fix: re-able discord notification - delete test workflow --- .github/workflows/nim_waku_daily_test.yml | 21 --------------------- .github/workflows/test_common.yml | 18 +++++++++--------- 2 files changed, 9 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/nim_waku_daily_test.yml diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml deleted file mode 100644 index 89084219cf..0000000000 --- a/.github/workflows/nim_waku_daily_test.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Test Nim -> Nim Waku Interop Tests - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: false - -on: - push: - branches: - - chore-rln-relay-tests - workflow_dispatch: - -jobs: - test-common: - uses: ./.github/workflows/test_common.yml - secrets: inherit - with: - node1: "harbor.status.im/wakuorg/nwaku:latest" - node2: "harbor.status.im/wakuorg/nwaku:latest" - additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" - caller: "nim" diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 77f7fb5851..21e5a757aa 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -101,12 +101,12 @@ jobs: echo EOF } >> $GITHUB_ENV -# - name: Send report to Discord -# uses: rjstone/discord-webhook-notify@v1 -# if: always() && env.CALLER != 'manual' -# with: -# severity: ${{ job.status == 'success' && 'info' || 'error' }} -# username: ${{ github.workflow }} -# description: "## Job Result: ${{ job.status }}" -# details: ${{ env.JOB_SUMMARY }} -# webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} + - name: Send report to Discord + uses: rjstone/discord-webhook-notify@v1 + if: always() && env.CALLER != 'manual' + with: + severity: ${{ job.status == 'success' && 'info' || 'error' }} + username: ${{ github.workflow }} + description: "## Job Result: ${{ job.status }}" + details: ${{ env.JOB_SUMMARY }} + webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} From e4b2b16cb93cc8a665b3d09215a2f8befbdd7891 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 21:35:43 +0800 Subject: [PATCH 136/139] test: re-test again after rebase --- .github/workflows/nim_waku_daily_test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/nim_waku_daily_test.yml diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml new file mode 100644 index 0000000000..e29e3db288 --- /dev/null +++ b/.github/workflows/nim_waku_daily_test.yml @@ -0,0 +1,21 @@ +name: Test Nim -> Nim Waku Interop Tests + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: false + +on: + push: + branches: + - chore-rln-relay-tests + workflow_dispatch: + +jobs: + test-common: + uses: ./.github/workflows/test_common.yml + secrets: inherit + with: + node1: "harbor.status.im/wakuorg/nwaku:latest" + node2: "harbor.status.im/wakuorg/nwaku:latest" + additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" + caller: "nim" \ No newline at end of file From 0b3ac5e35ef824d99f876de994694d01848a0015 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 6 May 2024 21:59:36 +0800 Subject: [PATCH 137/139] fix: wait longer for credential store --- src/node/waku_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/waku_node.py b/src/node/waku_node.py index 62d0595b44..24e57bf2a4 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -31,7 +31,7 @@ def sanitize_docker_flags(input_flags): return output_flags -@retry(stop=stop_after_delay(120), wait=wait_fixed(0.5), reraise=True) +@retry(stop=stop_after_delay(180), wait=wait_fixed(0.5), reraise=True) def rln_credential_store_ready(creds_file_path): if os.path.exists(creds_file_path): return True From 4abd6a4a8c710e482b8f3cd60c0e85765afd88aa Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 7 May 2024 07:56:24 +0800 Subject: [PATCH 138/139] test: try again with Discord report off --- .github/workflows/test_common.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 21e5a757aa..77f7fb5851 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -101,12 +101,12 @@ jobs: echo EOF } >> $GITHUB_ENV - - name: Send report to Discord - uses: rjstone/discord-webhook-notify@v1 - if: always() && env.CALLER != 'manual' - with: - severity: ${{ job.status == 'success' && 'info' || 'error' }} - username: ${{ github.workflow }} - description: "## Job Result: ${{ job.status }}" - details: ${{ env.JOB_SUMMARY }} - webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} +# - name: Send report to Discord +# uses: rjstone/discord-webhook-notify@v1 +# if: always() && env.CALLER != 'manual' +# with: +# severity: ${{ job.status == 'success' && 'info' || 'error' }} +# username: ${{ github.workflow }} +# description: "## Job Result: ${{ job.status }}" +# details: ${{ env.JOB_SUMMARY }} +# webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} From 01978d3a5b37b9e1900e1acc4ee3d3ca24466c73 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 7 May 2024 08:28:20 +0800 Subject: [PATCH 139/139] fix: enable Discord - delete test workflow --- .github/workflows/nim_waku_daily_test.yml | 21 --------------------- .github/workflows/test_common.yml | 18 +++++++++--------- 2 files changed, 9 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/nim_waku_daily_test.yml diff --git a/.github/workflows/nim_waku_daily_test.yml b/.github/workflows/nim_waku_daily_test.yml deleted file mode 100644 index e29e3db288..0000000000 --- a/.github/workflows/nim_waku_daily_test.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Test Nim -> Nim Waku Interop Tests - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: false - -on: - push: - branches: - - chore-rln-relay-tests - workflow_dispatch: - -jobs: - test-common: - uses: ./.github/workflows/test_common.yml - secrets: inherit - with: - node1: "harbor.status.im/wakuorg/nwaku:latest" - node2: "harbor.status.im/wakuorg/nwaku:latest" - additional_nodes: "harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest,harbor.status.im/wakuorg/nwaku:latest" - caller: "nim" \ No newline at end of file diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 77f7fb5851..21e5a757aa 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -101,12 +101,12 @@ jobs: echo EOF } >> $GITHUB_ENV -# - name: Send report to Discord -# uses: rjstone/discord-webhook-notify@v1 -# if: always() && env.CALLER != 'manual' -# with: -# severity: ${{ job.status == 'success' && 'info' || 'error' }} -# username: ${{ github.workflow }} -# description: "## Job Result: ${{ job.status }}" -# details: ${{ env.JOB_SUMMARY }} -# webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }} + - name: Send report to Discord + uses: rjstone/discord-webhook-notify@v1 + if: always() && env.CALLER != 'manual' + with: + severity: ${{ job.status == 'success' && 'info' || 'error' }} + username: ${{ github.workflow }} + description: "## Job Result: ${{ job.status }}" + details: ${{ env.JOB_SUMMARY }} + webhookUrl: ${{ secrets.DISCORD_TEST_REPORTS_WH }}