Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: RLN relay tests #30

Merged
merged 145 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
548b4f7
fix: add get_multiaddr_with_id step
romanzac Apr 12, 2024
ef05d29
fix: discard containers used for RLN registration
romanzac Apr 15, 2024
004b8f6
Merge branch 'master' into chore-rln-relay-tests
romanzac Apr 15, 2024
5ee97c6
fix: switch to use cluster ID 1 for RLN
romanzac Apr 15, 2024
c4f48e7
test: publish at slow and spam rate
romanzac Apr 15, 2024
ea63da2
fix: shorten test data set
romanzac Apr 15, 2024
896bf25
fix: move RLN related code into separate class
romanzac Apr 16, 2024
ab06596
fix: use send only publish function
romanzac Apr 17, 2024
742a00b
fix: use math.trunc instead of rounding
romanzac Apr 17, 2024
14b113a
fix: first message without delay
romanzac Apr 17, 2024
12e287c
fix: add one more second to messages with delay
romanzac Apr 17, 2024
84fe165
fix: add methods to setup non default RLN nodes
romanzac Apr 18, 2024
678bbe1
Merge branch 'master' into chore-rln-relay-tests
romanzac Apr 18, 2024
aa8177c
fix: rewrite tests using steps rather than fixtures
romanzac Apr 18, 2024
309cfbc
test: random epoch with valid_payloads_at_slow_rate
romanzac Apr 18, 2024
b1316a9
test: random user message limit with valid payloads
romanzac Apr 18, 2024
2adc825
Merge branch 'master' into chore-rln-relay-tests
romanzac Apr 18, 2024
946d893
fix: skip test "random user message limit with valid payloads"
romanzac Apr 19, 2024
a247e39
fix: mark flaky "at variable_rate with valid payloads"
romanzac Apr 19, 2024
54cc4ff
fix: rename tests for easier debugging
romanzac Apr 19, 2024
a539dcc
fix: mark valid_payloads_dynamic_at_slow_rate to skip
romanzac Apr 22, 2024
2c81b2d
fix: forgot to add actual file
romanzac Apr 22, 2024
efeed3d
test: valid payloads dynamic(on chain) at spam rate
romanzac Apr 23, 2024
472aa81
fix: revert env_vars to source images from Harbor
romanzac Apr 23, 2024
19cd709
Merge branch 'master' into chore-rln-relay-tests
romanzac Apr 23, 2024
b751466
fix: reuse setup first and second rln relay node for setup_main_rln_r…
romanzac Apr 23, 2024
84fb188
fix: reuse register_rln_single_node for register_main_rln_relay_nodes
romanzac Apr 23, 2024
6b3c8c3
fix: start using src.steps.common
romanzac Apr 23, 2024
31afbcf
fix: test using whole data set at test payloads_at_slow_rate
romanzac Apr 23, 2024
8b69685
fix: switch to send msg and check for slow rate tests
romanzac Apr 24, 2024
29cdee2
fix: add comment for skip check at first message
romanzac Apr 24, 2024
5e3df53
fix: refactor payloads_at_variable_rate to use only one payload pattern
romanzac Apr 24, 2024
a8e2263
fix: remove the plural from payloads_at_variable_rate
romanzac Apr 24, 2024
8fd9520
fix: multiple class inheritance for TestRelayRLN
romanzac Apr 24, 2024
0022c94
test: node1 with rln node2 without rln at spam rate
romanzac Apr 25, 2024
696b85f
test: mixed epoch at slow rate
romanzac Apr 25, 2024
5b3ab13
test: add lightpush methods
romanzac Apr 25, 2024
7f86deb
test: send valid payloads lightpush at spam rate
romanzac Apr 25, 2024
b6e14e5
fix: node1 to act as light push receiving node
romanzac Apr 26, 2024
e877df7
fix: use NODE1 NODE2 instead of DEFAULT_NWAKU
romanzac Apr 26, 2024
345f3f5
fix: no lightpush param required for plain RLN relay
romanzac Apr 26, 2024
939c0b5
fix: comment for lightpush
romanzac Apr 26, 2024
7e415f6
fix: comment for lightpush - wait for implementation
romanzac Apr 26, 2024
f969375
fix: comment on chain tests
romanzac Apr 26, 2024
00eeaa5
fix: add lightpush case to publish_message
romanzac Apr 29, 2024
f67a73e
fix: remove check_light_pushed_message_reaches_receiving_peer from St…
romanzac Apr 29, 2024
ee2e056
fix: change comment for mixed_epoch_at_slow_rate
romanzac Apr 30, 2024
58f89c6
test: happy and common case with 5 nodes
romanzac Apr 30, 2024
f4a50ca
fix: add all required fixtures explicitly
romanzac Apr 30, 2024
3dcc00c
fix: add timeout param to ensure_ready
romanzac Apr 30, 2024
ab63244
fix: skip RLN tests for go-waku
romanzac Apr 30, 2024
1e463cd
fix: reformated with pre-commit
romanzac Apr 30, 2024
3b5680f
Merge branch 'master' into chore-rln-relay-tests
romanzac Apr 30, 2024
73d0951
fix: uncomment skip for debugging
romanzac May 3, 2024
d3e14e0
fix: put the skip back
romanzac May 3, 2024
2661438
fix: change comment for on chain tests
romanzac May 6, 2024
f108cb9
fix: run RLN tests in serial
romanzac May 6, 2024
c00ff1a
test: Nim to Nim workflow
romanzac May 6, 2024
24f6674
test: check also additional nodes for go-waku
romanzac May 6, 2024
cb2632c
test: all nodes are nwaku
romanzac May 6, 2024
1ab141f
fix: string quotes
romanzac May 6, 2024
1423e53
fix: remove additional nodes
romanzac May 6, 2024
7804302
fix: re-arrange skip conditions
romanzac May 6, 2024
842f7ce
test: RLN only
romanzac May 6, 2024
4379642
fix: change default additional nodes to nwaku only
romanzac May 6, 2024
3452bed
fix: change additional nodes rather at top level workflow
romanzac May 6, 2024
2db8c38
fix: enable all tests
romanzac May 6, 2024
efaf22a
test: problems with current workdir
romanzac May 6, 2024
94e735a
test: rln only
romanzac May 6, 2024
1856d3e
test: correct typo
romanzac May 6, 2024
b92250f
test: re-enable all tests
romanzac May 6, 2024
9f2ccf1
fix: nwaku additional nodes for nim to nim worklfow
romanzac May 6, 2024
8767685
fix: re-able discord notification
romanzac May 6, 2024
50e827c
fix: add get_multiaddr_with_id step
romanzac Apr 12, 2024
e6d56d1
fix: discard containers used for RLN registration
romanzac Apr 15, 2024
e3981ff
fix: switch to use cluster ID 1 for RLN
romanzac Apr 15, 2024
add1b82
test: publish at slow and spam rate
romanzac Apr 15, 2024
241397b
fix: shorten test data set
romanzac Apr 15, 2024
2175c77
fix: rebase onto master
romanzac Apr 16, 2024
ab37b02
fix: use send only publish function
romanzac Apr 17, 2024
0676a49
fix: use math.trunc instead of rounding
romanzac Apr 17, 2024
8229e63
fix: first message without delay
romanzac Apr 17, 2024
b720ba7
fix: add one more second to messages with delay
romanzac Apr 17, 2024
06bd935
fix: add methods to setup non default RLN nodes
romanzac Apr 18, 2024
43f36c8
fix: rewrite tests using steps rather than fixtures
romanzac Apr 18, 2024
5e927b8
test: random epoch with valid_payloads_at_slow_rate
romanzac Apr 18, 2024
38382dd
test: random user message limit with valid payloads
romanzac Apr 18, 2024
f814a68
fix: skip test "random user message limit with valid payloads"
romanzac Apr 19, 2024
01fae78
fix: mark flaky "at variable_rate with valid payloads"
romanzac Apr 19, 2024
cca30d5
fix: rename tests for easier debugging
romanzac Apr 19, 2024
f699099
fix: mark valid_payloads_dynamic_at_slow_rate to skip
romanzac Apr 22, 2024
027b446
fix: forgot to add actual file
romanzac Apr 22, 2024
a034ad6
test: valid payloads dynamic(on chain) at spam rate
romanzac Apr 23, 2024
b67faa9
fix: revert env_vars to source images from Harbor
romanzac Apr 23, 2024
dd17131
fix: reuse setup first and second rln relay node for setup_main_rln_r…
romanzac Apr 23, 2024
99387d6
fix: reuse register_rln_single_node for register_main_rln_relay_nodes
romanzac Apr 23, 2024
2a38bae
fix: start using src.steps.common
romanzac Apr 23, 2024
36123ae
fix: test using whole data set at test payloads_at_slow_rate
romanzac Apr 23, 2024
07046b8
fix: switch to send msg and check for slow rate tests
romanzac Apr 24, 2024
71db6ba
fix: add comment for skip check at first message
romanzac Apr 24, 2024
18d0bd3
fix: refactor payloads_at_variable_rate to use only one payload pattern
romanzac Apr 24, 2024
776828c
fix: remove the plural from payloads_at_variable_rate
romanzac Apr 24, 2024
285a652
fix: multiple class inheritance for TestRelayRLN
romanzac Apr 24, 2024
bab2574
test: node1 with rln node2 without rln at spam rate
romanzac Apr 25, 2024
d9d71a6
test: mixed epoch at slow rate
romanzac Apr 25, 2024
e6a138b
test: add lightpush methods
romanzac Apr 25, 2024
3386afa
test: send valid payloads lightpush at spam rate
romanzac Apr 25, 2024
475588e
fix: node1 to act as light push receiving node
romanzac Apr 26, 2024
44b404b
fix: use NODE1 NODE2 instead of DEFAULT_NWAKU
romanzac Apr 26, 2024
2997132
fix: no lightpush param required for plain RLN relay
romanzac Apr 26, 2024
786a79b
fix: comment for lightpush
romanzac Apr 26, 2024
4f0e7f0
fix: comment for lightpush - wait for implementation
romanzac Apr 26, 2024
056c8e0
fix: comment on chain tests
romanzac Apr 26, 2024
8fe1844
fix: add lightpush case to publish_message
romanzac Apr 29, 2024
17816e3
fix: remove check_light_pushed_message_reaches_receiving_peer from St…
romanzac Apr 29, 2024
4829859
fix: change comment for mixed_epoch_at_slow_rate
romanzac Apr 30, 2024
5d1b4f5
test: happy and common case with 5 nodes
romanzac Apr 30, 2024
cb6a2b8
fix: add all required fixtures explicitly
romanzac Apr 30, 2024
b11826e
fix: add timeout param to ensure_ready
romanzac Apr 30, 2024
8cd290f
fix: skip RLN tests for go-waku
romanzac Apr 30, 2024
b415126
fix: uncomment skip for debugging
romanzac May 3, 2024
f9f6b02
fix: put the skip back
romanzac May 3, 2024
3143d33
fix: change comment for on chain tests
romanzac May 6, 2024
e61be72
fix: run RLN tests in serial
romanzac May 6, 2024
a679568
test: Nim to Nim workflow
romanzac May 6, 2024
7e74f25
test: check also additional nodes for go-waku
romanzac May 6, 2024
c03335b
test: all nodes are nwaku
romanzac May 6, 2024
e93b321
fix: string quotes
romanzac May 6, 2024
778acb1
fix: remove additional nodes
romanzac May 6, 2024
7d31259
fix: re-arrange skip conditions
romanzac May 6, 2024
90f9332
test: RLN only
romanzac May 6, 2024
42b5dcf
fix: change default additional nodes to nwaku only
romanzac May 6, 2024
de14521
fix: change additional nodes rather at top level workflow
romanzac May 6, 2024
340ea54
fix: enable all tests
romanzac May 6, 2024
55f6ff2
test: problems with current workdir
romanzac May 6, 2024
0ca41c4
test: rln only
romanzac May 6, 2024
eb8a7c6
test: correct typo
romanzac May 6, 2024
1cad269
test: re-enable all tests
romanzac May 6, 2024
67fb3b9
fix: nwaku additional nodes for nim to nim worklfow
romanzac May 6, 2024
a73dec0
fix: re-able discord notification
romanzac May 6, 2024
1c8776b
Merge remote-tracking branch 'origin/chore-rln-relay-tests' into chor…
romanzac May 6, 2024
e4b2b16
test: re-test again after rebase
romanzac May 6, 2024
0b3ac5e
fix: wait longer for credential store
romanzac May 6, 2024
4abd6a4
test: try again with Discord report off
romanzac May 6, 2024
01978d3
fix: enable Discord
romanzac May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/nim_waku_daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion .github/workflows/test_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ 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()
Expand Down
9 changes: 9 additions & 0 deletions src/node/api_clients/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
27 changes: 20 additions & 7 deletions src/node/waku_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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
)
Expand All @@ -121,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
Expand Down Expand Up @@ -184,10 +186,18 @@ 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)
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 !!")

check_ready()

@retry(stop=stop_after_delay(10), wait=wait_fixed(1), reraise=True)
def ensure_healthy(self):
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
self.health_response = self.health()
logger.info("Node is healthy !!")

def get_enr_uri(self):
try:
Expand All @@ -208,6 +218,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()

Expand Down
45 changes: 2 additions & 43 deletions src/steps/relay.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"Registering RLN credentials: {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.main_nodes.extend([self.node1, self.node2])

@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.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}")
Expand Down Expand Up @@ -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
178 changes: 178 additions & 0 deletions src/steps/rln.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import os
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, 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

logger = get_custom_logger(__name__)


class StepsRLN(StepsCommon):
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 = []
multiaddr_list = []
lightpush_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.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)
self.setup_second_rln_relay_node(**kwargs)

@allure.step
def setup_first_rln_relay_node(self, **kwargs):
self.node1 = WakuNode(NODE_1, 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])

self.multiaddr_list.extend([self.node1.get_multiaddr_with_id()])

@allure.step
def setup_second_rln_relay_node(self, **kwargs):
self.node2 = WakuNode(NODE_2, 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,
)
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}")
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])
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):
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()
self.main_nodes.extend([self.node1])

@allure.step
def setup_second_relay_node(self, **kwargs):
self.node2 = WakuNode(NODE_2, f"node2_{self.test_id}")
self.node2.start(
relay="true",
discv5_bootstrap_node=self.enr_uri,
**kwargs,
)
self.add_node_peer(self.node2, [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")
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

@allure.step
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:
pubsub_topic = self.test_pubsub_topic
if not sender:
sender = self.node1

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):
for node in node_list:
node.set_relay_subscriptions(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 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:
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
2 changes: 2 additions & 0 deletions src/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Loading
Loading