lightpush changes (#64)

* lightpush changes

* lightpush changes
This commit is contained in:
fbarbu15 2024-08-05 16:51:48 +03:00 committed by GitHub
parent 4e96452119
commit 68c4b57c08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 33 additions and 18 deletions

View File

@ -21,6 +21,10 @@ class TestDiscv5(StepsRelay, StepsFilter, StepsStore, StepsLightPush):
self.publish_message()
self.check_published_message_is_stored([self.store_node1], page_size=5, ascending="true")
@retry(stop=stop_after_delay(70), wait=wait_fixed(1), reraise=True)
def wait_for_lightpushed_message_to_be_stored(self):
self.check_light_pushed_message_reaches_receiving_peer(peer_list=[self.receiving_node1, self.receiving_node2])
def test_relay(self):
self.node1 = self.running_a_node(NODE_1, relay="true", nodekey=NODEKEY)
self.node2 = self.running_a_node(NODE_2, relay="true", discv5_bootstrap_node=self.node1.get_enr_uri())
@ -52,6 +56,7 @@ class TestDiscv5(StepsRelay, StepsFilter, StepsStore, StepsLightPush):
def test_lightpush(self):
self.receiving_node1 = self.running_a_node(NODE_1, lightpush="true", relay="true", nodekey=NODEKEY)
self.receiving_node2 = self.running_a_node(NODE_1, lightpush="false", relay="true", discv5_bootstrap_node=self.receiving_node1.get_enr_uri())
self.light_push_node1 = self.running_a_node(
NODE_2,
lightpush="true",
@ -59,5 +64,5 @@ class TestDiscv5(StepsRelay, StepsFilter, StepsStore, StepsLightPush):
discv5_bootstrap_node=self.receiving_node1.get_enr_uri(),
lightpushnode=self.receiving_node1.get_multiaddr_with_id(),
)
self.subscribe_to_pubsub_topics_via_relay(self.receiving_node1)
self.check_light_pushed_message_reaches_receiving_peer(peer_list=[self.receiving_node1])
self.subscribe_to_pubsub_topics_via_relay([self.receiving_node1, self.receiving_node2])
self.wait_for_lightpushed_message_to_be_stored()

View File

@ -1,16 +1,9 @@
from src.env_vars import NODE_1
from src.libs.common import delay
from src.steps.light_push import StepsLightPush
class TestMultipleNodes(StepsLightPush):
def test_2_lightpush_nodes_and_1_receiving_node(self):
self.setup_first_receiving_node(lightpush="true", relay="true")
self.setup_first_lightpush_node(lightpush="true", relay="false")
self.setup_second_lightpush_node(lightpush="true", relay="false")
self.subscribe_to_pubsub_topics_via_relay()
self.check_light_pushed_message_reaches_receiving_peer(sender=self.light_push_node1)
self.check_light_pushed_message_reaches_receiving_peer(sender=self.light_push_node2)
def test_2_receiving_nodes__relay_node1_forwards_lightpushed_message_to_relay_node2(self):
self.setup_first_receiving_node(lightpush="true", relay="true")
self.setup_second_receiving_node(lightpush="false", relay="true")
@ -22,7 +15,8 @@ class TestMultipleNodes(StepsLightPush):
self.setup_first_receiving_node(lightpush="true", relay="true", filter="true")
self.setup_second_receiving_node(lightpush="false", relay="false", filternode=self.receiving_node1.get_multiaddr_with_id())
self.setup_first_lightpush_node(lightpush="true", relay="false")
self.subscribe_to_pubsub_topics_via_relay(node=self.receiving_node1)
helper_node = self.start_receiving_node(NODE_1, node_index=4, lightpush="false", relay="true")
self.subscribe_to_pubsub_topics_via_relay(node=[self.receiving_node1, helper_node])
self.subscribe_to_pubsub_topics_via_filter(node=self.receiving_node2)
self.check_light_pushed_message_reaches_receiving_peer(sender=self.light_push_node1)
get_messages_response = self.receiving_node2.get_filter_messages(self.test_content_topic)
@ -60,6 +54,7 @@ class TestMultipleNodes(StepsLightPush):
def test_multiple_lightpush_nodes(self):
self.setup_first_receiving_node(lightpush="true", relay="true")
self.setup_second_receiving_node(lightpush="false", relay="true")
self.setup_first_lightpush_node(lightpush="true", relay="false")
self.setup_additional_lightpush_nodes()
self.subscribe_to_pubsub_topics_via_relay()

View File

@ -13,6 +13,7 @@ class TestLightPushPublish(StepsLightPush):
@pytest.fixture(scope="function", autouse=True)
def light_push_publish_setup(self, light_push_setup):
self.setup_first_receiving_node()
self.setup_second_receiving_node(lightpush="false", relay="true")
self.setup_first_lightpush_node()
self.subscribe_to_pubsub_topics_via_relay()
@ -126,13 +127,12 @@ class TestLightPushPublish(StepsLightPush):
messages = self.receiving_node1.get_relay_messages(VALID_PUBSUB_TOPICS[1])
assert not messages, "Message was retrieved on wrong pubsub_topic"
@pytest.mark.xfail("go-waku" in NODE_2, reason="https://github.com/waku-org/go-waku/issues/1078")
def test_light_push_on_non_subscribed_pubsub_topic(self):
try:
self.check_light_pushed_message_reaches_receiving_peer(pubsub_topic=VALID_PUBSUB_TOPICS[1])
raise AssertionError("Light push on unsubscribed pubsub_topic worked!!!")
except Exception as ex:
assert "Not Found" in str(ex) or "Internal Server Error" in str(ex)
assert "Lightpush request has not been published to any peers" in str(ex)
def test_light_push_with_invalid_pubsub_topics(self):
success_content_topics = []
@ -147,10 +147,10 @@ class TestLightPushPublish(StepsLightPush):
@pytest.mark.xfail("go-waku" in NODE_2, reason="https://github.com/waku-org/go-waku/issues/1078")
def test_light_push_with_missing_pubsub_topics(self):
self.light_push_node1.send_light_push_message({"message": self.create_message()})
delay(0.1)
messages = self.receiving_node1.get_relay_messages(self.test_pubsub_topic)
assert len(messages) == 0
try:
self.light_push_node1.send_light_push_message({"message": self.create_message()})
except Exception as ex:
assert "Lightpush request has not been published to any peer" in str(ex)
def test_light_push_with_valid_timestamps(self):
failed_timestamps = []
@ -235,7 +235,10 @@ class TestLightPushPublish(StepsLightPush):
def test_light_push_and_retrieve_duplicate_message(self):
message = self.create_message()
self.check_light_pushed_message_reaches_receiving_peer(message=message)
self.check_light_pushed_message_reaches_receiving_peer(message=message)
try:
self.check_light_pushed_message_reaches_receiving_peer(message=message)
except Exception as ex:
assert "Lightpush request has not been published to any peer" in str(ex)
def test_light_push_while_peer_is_paused(self):
message = self.create_message()
@ -265,6 +268,7 @@ class TestLightPushPublish(StepsLightPush):
self.check_light_pushed_message_reaches_receiving_peer()
self.receiving_node1.restart()
self.receiving_node1.ensure_ready()
delay(30)
self.subscribe_to_pubsub_topics_via_relay()
self.check_light_pushed_message_reaches_receiving_peer()

View File

@ -33,6 +33,7 @@ class TestRunningNodes(StepsLightPush):
def test_main_node_only_lightpush__peer_full(self):
self.setup_first_receiving_node(lightpush="true", relay="true", filter="true")
self.setup_second_receiving_node(lightpush="false", relay="true")
self.setup_first_lightpush_node(lightpush="true", relay="false")
self.subscribe_to_pubsub_topics_via_relay()
self.check_light_pushed_message_reaches_receiving_peer()
@ -53,3 +54,12 @@ class TestRunningNodes(StepsLightPush):
assert len(response1) == 2
response2 = self.light_push_node1.get_relay_messages(self.test_pubsub_topic)
assert len(response2) == 2
def test_lightpush_with_a_single_receiving_node(self):
self.setup_first_receiving_node(lightpush="true", relay="true")
self.setup_first_lightpush_node(lightpush="true", relay="false")
self.subscribe_to_pubsub_topics_via_relay()
try:
self.check_light_pushed_message_reaches_receiving_peer(sender=self.light_push_node1)
except Exception as ex:
assert "Lightpush request has not been published to any peers" in str(ex)

View File

@ -61,6 +61,7 @@ class TestRunningNodes(StepsStore):
def test_store_lightpushed_message(self):
self.setup_first_publishing_node(store="true", relay="true", lightpush="true")
self.setup_second_publishing_node(store="false", relay="true")
self.setup_first_store_node(store="false", relay="false", lightpush="true", lightpushnode=self.multiaddr_list[0])
self.subscribe_to_pubsub_topics_via_relay()
self.publish_message(via="lightpush", sender=self.store_node1)