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 22 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
4 changes: 2 additions & 2 deletions src/env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
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}")
Expand Down
2 changes: 2 additions & 0 deletions src/node/waku_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
46 changes: 2 additions & 44 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.test_data import VALID_PUBSUB_TOPICS

Expand Down Expand Up @@ -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"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"
)
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}")
Expand Down Expand Up @@ -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
110 changes: 110 additions & 0 deletions src/steps/rln.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
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
import inspect
import pytest
import allure
from time import time
from src.node.waku_node import WakuNode, rln_credential_store_ready
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}")
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
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}")
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
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():
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
self.node2.add_peers([self.multiaddr_with_id])
self.main_nodes.extend([self.node1, self.node2])

@allure.step
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()
self.multiaddr_with_id = self.node1.get_multiaddr_with_id()
self.main_nodes.extend([self.node1])

@allure.step
def setup_second_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")
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 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):
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
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)

@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])
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"]
127 changes: 113 additions & 14 deletions tests/relay/test_rln.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,123 @@
import os
import math
import random
from time import time

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.steps.rln import StepsRLN
from src.test_data import SAMPLE_INPUTS

logger = get_custom_logger(__name__)


@pytest.mark.usefixtures()
class TestRelayRLN(StepsRelay):
def test_register_rln(self):
logger.debug("Running register RLN test for main relay nodes")
key_stores_found = 0
@pytest.mark.usefixtures("register_main_rln_relay_nodes")
class TestRelayRLN(StepsRLN, StepsRelay):
def test_publish_with_valid_payloads_at_slow_rate(self):
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
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"]}')
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
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}"

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"]}')
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
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:
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
raise AssertionError("Publish with RLN enabled at spam rate worked!!!")
fbarbu15 marked this conversation as resolved.
Show resolved Hide resolved
else:
previous = now
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()
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(1 + 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)

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.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}"

if RLN_CREDENTIALS is None:
pytest.skip("RLN_CREDENTIALS not set, skipping test")
@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.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}"

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}"
@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")
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}"
Loading