mirror of
https://github.com/logos-messaging/logos-messaging-interop-tests.git
synced 2026-05-05 18:09:25 +00:00
new tests
This commit is contained in:
parent
aee2128b7e
commit
1c1b147bc4
@ -14,8 +14,8 @@ def get_env_var(var_name, default=None):
|
|||||||
|
|
||||||
|
|
||||||
# Configuration constants. Need to be upercase to appear in reports
|
# Configuration constants. Need to be upercase to appear in reports
|
||||||
NODE_1 = get_env_var("NODE_1", "wakuorg/nwaku:latest")
|
NODE_1 = get_env_var("NODE_1", "wakuorg/go-waku:latest")
|
||||||
NODE_2 = get_env_var("NODE_2", "wakuorg/go-waku:latest")
|
NODE_2 = get_env_var("NODE_2", "wakuorg/nwaku:latest")
|
||||||
DOCKER_LOG_DIR = get_env_var("DOCKER_LOG_DIR", "./log/docker")
|
DOCKER_LOG_DIR = get_env_var("DOCKER_LOG_DIR", "./log/docker")
|
||||||
NETWORK_NAME = get_env_var("NETWORK_NAME", "waku")
|
NETWORK_NAME = get_env_var("NETWORK_NAME", "waku")
|
||||||
SUBNET = get_env_var("SUBNET", "172.18.0.0/16")
|
SUBNET = get_env_var("SUBNET", "172.18.0.0/16")
|
||||||
|
|||||||
@ -86,6 +86,21 @@ class WakuNode:
|
|||||||
self._container.stop()
|
self._container.stop()
|
||||||
logger.debug("Container stopped.")
|
logger.debug("Container stopped.")
|
||||||
|
|
||||||
|
def restart(self):
|
||||||
|
if self._container:
|
||||||
|
logger.debug("Restarting container with id %s", self._container.short_id)
|
||||||
|
self._container.restart()
|
||||||
|
|
||||||
|
def pause(self):
|
||||||
|
if self._container:
|
||||||
|
logger.debug("Pausing container with id %s", self._container.short_id)
|
||||||
|
self._container.pause()
|
||||||
|
|
||||||
|
def unpause(self):
|
||||||
|
if self._container:
|
||||||
|
logger.debug("Unpause container with id %s", 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(10), wait=wait_fixed(0.1), reraise=True)
|
||||||
def ensure_ready(self):
|
def ensure_ready(self):
|
||||||
self.info()
|
self.info()
|
||||||
|
|||||||
@ -28,11 +28,9 @@ class StepsRelay:
|
|||||||
self.node2.set_subscriptions([self.test_pubsub_topic])
|
self.node2.set_subscriptions([self.test_pubsub_topic])
|
||||||
|
|
||||||
@pytest.fixture(scope="function", autouse=True)
|
@pytest.fixture(scope="function", autouse=True)
|
||||||
@retry(stop=stop_after_delay(120), wait=wait_fixed(1), reraise=True)
|
def network_warm_up(self, setup_nodes):
|
||||||
def wait_for_network_to_warm_up(self):
|
|
||||||
message = {"payload": to_base64(self.test_payload), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)}
|
|
||||||
try:
|
try:
|
||||||
self.check_published_message_reaches_peer(message)
|
self.wait_for_published_message_to_reach_peer(120)
|
||||||
logger.info("WARM UP successful !!")
|
logger.info("WARM UP successful !!")
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise Exception(f"WARM UP FAILED WITH: {ex}")
|
raise Exception(f"WARM UP FAILED WITH: {ex}")
|
||||||
@ -73,3 +71,11 @@ class StepsRelay:
|
|||||||
assert str(received_message.ephemeral) == str(sent_message["ephemeral"]), assert_fail_message("ephemeral")
|
assert str(received_message.ephemeral) == str(sent_message["ephemeral"]), assert_fail_message("ephemeral")
|
||||||
if "rateLimitProof" in sent_message and sent_message["rateLimitProof"]:
|
if "rateLimitProof" in sent_message and sent_message["rateLimitProof"]:
|
||||||
assert str(received_message.rateLimitProof) == str(sent_message["rateLimitProof"]), assert_fail_message("rateLimitProof")
|
assert str(received_message.rateLimitProof) == str(sent_message["rateLimitProof"]), assert_fail_message("rateLimitProof")
|
||||||
|
|
||||||
|
def wait_for_published_message_to_reach_peer(self, timeout_duration, time_between_retries=1):
|
||||||
|
@retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(time_between_retries), reraise=True)
|
||||||
|
def check_peer_connection():
|
||||||
|
message = {"payload": to_base64(self.test_payload), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)}
|
||||||
|
self.check_published_message_reaches_peer(message)
|
||||||
|
|
||||||
|
check_peer_connection()
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
from src.libs.custom_logger import get_custom_logger
|
from src.libs.custom_logger import get_custom_logger
|
||||||
from time import time
|
from time import sleep, time
|
||||||
from src.libs.common import to_base64
|
from src.libs.common import to_base64
|
||||||
from src.steps.relay import StepsRelay
|
from src.steps.relay import StepsRelay
|
||||||
from src.test_data import INVALID_CONTENT_TOPICS, INVALID_PAYLOADS, SAMPLE_INPUTS, SAMPLE_TIMESTAMPS
|
from src.test_data import INVALID_CONTENT_TOPICS, INVALID_PAYLOADS, SAMPLE_INPUTS, SAMPLE_TIMESTAMPS
|
||||||
|
import pytest
|
||||||
|
|
||||||
logger = get_custom_logger(__name__)
|
logger = get_custom_logger(__name__)
|
||||||
|
|
||||||
@ -150,14 +151,6 @@ class TestRelayPublish(StepsRelay):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
assert "Bad Request" in str(ex)
|
assert "Bad Request" in str(ex)
|
||||||
|
|
||||||
def test_publish_with_rate_limit_proof(self):
|
|
||||||
self.test_message["rateLimitProof"] = {
|
|
||||||
"proof": to_base64("proofData"),
|
|
||||||
"epoch": to_base64("epochData"),
|
|
||||||
"nullifier": to_base64("nullifierData"),
|
|
||||||
}
|
|
||||||
self.check_published_message_reaches_peer(self.test_message)
|
|
||||||
|
|
||||||
def test_publish_with_ephemeral(self):
|
def test_publish_with_ephemeral(self):
|
||||||
failed_ephemeral = []
|
failed_ephemeral = []
|
||||||
for ephemeral in [True, False]:
|
for ephemeral in [True, False]:
|
||||||
@ -170,6 +163,18 @@ class TestRelayPublish(StepsRelay):
|
|||||||
failed_ephemeral.append(ephemeral)
|
failed_ephemeral.append(ephemeral)
|
||||||
assert not failed_ephemeral, f"Ephemeral that failed: {failed_ephemeral}"
|
assert not failed_ephemeral, f"Ephemeral that failed: {failed_ephemeral}"
|
||||||
|
|
||||||
|
def test_publish_with_rate_limit_proof(self):
|
||||||
|
self.test_message["rateLimitProof"] = {
|
||||||
|
"proof": to_base64("proofData"),
|
||||||
|
"epoch": to_base64("epochData"),
|
||||||
|
"nullifier": to_base64("nullifierData"),
|
||||||
|
}
|
||||||
|
self.check_published_message_reaches_peer(self.test_message)
|
||||||
|
|
||||||
|
def test_publish_with_extra_field(self):
|
||||||
|
self.test_message["extraField"] = "extraValue"
|
||||||
|
self.check_published_message_reaches_peer(self.test_message)
|
||||||
|
|
||||||
def test_publish_and_retrieve_duplicate_message(self):
|
def test_publish_and_retrieve_duplicate_message(self):
|
||||||
self.check_published_message_reaches_peer(self.test_message)
|
self.check_published_message_reaches_peer(self.test_message)
|
||||||
try:
|
try:
|
||||||
@ -177,3 +182,29 @@ class TestRelayPublish(StepsRelay):
|
|||||||
raise AssertionError("Duplicate message was retrieved twice")
|
raise AssertionError("Duplicate message was retrieved twice")
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
assert "Peer node couldn't find any messages" in str(ex)
|
assert "Peer node couldn't find any messages" in str(ex)
|
||||||
|
|
||||||
|
def test_publish_after_node_pauses(self):
|
||||||
|
self.check_published_message_reaches_peer(self.test_message)
|
||||||
|
self.node1.pause()
|
||||||
|
self.node1.unpause()
|
||||||
|
self.test_message["payload"] = to_base64("new payload 1")
|
||||||
|
self.check_published_message_reaches_peer(self.test_message)
|
||||||
|
self.node2.pause()
|
||||||
|
self.node2.unpause()
|
||||||
|
self.test_message["payload"] = to_base64("new payload 2")
|
||||||
|
self.check_published_message_reaches_peer(self.test_message)
|
||||||
|
|
||||||
|
@pytest.mark.skip("enrUri resets after node restart and node2 looses connection")
|
||||||
|
def test_publish_after_node1_restarts(self):
|
||||||
|
self.check_published_message_reaches_peer(self.test_message)
|
||||||
|
self.node1.restart()
|
||||||
|
self.node1.set_subscriptions([self.test_pubsub_topic])
|
||||||
|
self.node2.set_subscriptions([self.test_pubsub_topic])
|
||||||
|
self.wait_for_published_message_to_reach_peer(20)
|
||||||
|
|
||||||
|
def test_publish_after_node2_restarts(self):
|
||||||
|
self.check_published_message_reaches_peer(self.test_message)
|
||||||
|
self.node2.restart()
|
||||||
|
self.node1.set_subscriptions([self.test_pubsub_topic])
|
||||||
|
self.node2.set_subscriptions([self.test_pubsub_topic])
|
||||||
|
self.wait_for_published_message_to_reach_peer(20)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user