Skip to content

Commit

Permalink
test: swap order of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
romanzac committed Aug 8, 2024
1 parent 7d3f6d2 commit 6dd787f
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions tests/relay/test_rln.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,48 +131,48 @@ class TestRelayRLN(StepsRLN, StepsRelay):

@pytest.mark.timeout(600)
@pytest.mark.usefixtures("register_main_rln_relay_nodes")
def test_valid_payloads_dynamic_at_slow_rate(self):
def test_valid_payloads_dynamic_at_spam_rate(self):
message_limit = 100
epoch_sec = 600
self.setup_main_rln_relay_nodes(
rln_relay_user_message_limit=message_limit, rln_relay_epoch_sec=600, rln_relay_dynamic="true", wait_for_node_sec=600
rln_relay_user_message_limit=message_limit, rln_relay_epoch_sec=epoch_sec, rln_relay_dynamic="true", wait_for_node_sec=600
)
self.subscribe_main_relay_nodes()
failed_payloads = []
start = math.trunc(time())
for i, payload in enumerate(self.SAMPLE_INPUTS_RLN):
logger.debug(f'Running test with payload {payload["description"]}')
message = self.create_message(payload=to_base64(payload["value"]))
try:
logger.debug(f"Sending message No. #{i + 1}")
self.check_published_message_reaches_relay_peer(message, message_propagation_delay=0.2)
now = math.trunc(time())
self.publish_message(message)
if i > message_limit and (now - start) <= epoch_sec:
raise AssertionError("Publish with RLN enabled at spam rate worked!!!")
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}"
if i == message_limit - 1:
break
assert "RLN validation failed" or "NonceLimitReached" in str(e)

@pytest.mark.timeout(600)
@pytest.mark.usefixtures("register_main_rln_relay_nodes")
def test_valid_payloads_dynamic_at_spam_rate(self):
def test_valid_payloads_dynamic_at_slow_rate(self):
message_limit = 100
epoch_sec = 600
self.setup_main_rln_relay_nodes(
rln_relay_user_message_limit=message_limit, rln_relay_epoch_sec=epoch_sec, rln_relay_dynamic="true", wait_for_node_sec=600
rln_relay_user_message_limit=message_limit, rln_relay_epoch_sec=600, rln_relay_dynamic="true", wait_for_node_sec=600
)
self.subscribe_main_relay_nodes()
start = math.trunc(time())
failed_payloads = []
for i, payload in enumerate(self.SAMPLE_INPUTS_RLN):
logger.debug(f'Running test with payload {payload["description"]}')
message = self.create_message(payload=to_base64(payload["value"]))
try:
logger.debug(f"Sending message No. #{i + 1}")
now = math.trunc(time())
self.publish_message(message)
if i > message_limit and (now - start) <= epoch_sec:
raise AssertionError("Publish with RLN enabled at spam rate worked!!!")
self.check_published_message_reaches_relay_peer(message, message_propagation_delay=0.2)
except Exception as e:
assert "RLN validation failed" or "NonceLimitReached" in str(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}"
if i == message_limit - 1:
break

# def test_valid_payloads_n1_with_rln_n2_without_rln_at_spam_rate(self):
# message_limit = 1
Expand Down

0 comments on commit 6dd787f

Please sign in to comment.