From 3c804d7d9bbb7b17f11e5126997f7700070b06a7 Mon Sep 17 00:00:00 2001 From: aya Date: Sat, 24 May 2025 21:02:29 +0300 Subject: [PATCH] Adding basic scenario to trigger sync --- src/node/api_clients/rest.py | 6 ++++++ src/node/waku_node.py | 6 ++++++ src/steps/store.py | 3 +++ tests/e2e/test_e2e.py | 7 +++++++ 4 files changed, 22 insertions(+) diff --git a/src/node/api_clients/rest.py b/src/node/api_clients/rest.py index 210cae38b28..12c8fdf5927 100644 --- a/src/node/api_clients/rest.py +++ b/src/node/api_clients/rest.py @@ -50,6 +50,12 @@ def delete_relay_auto_subscriptions(self, content_topics): def send_relay_message(self, message, pubsub_topic): return self.rest_call("post", f"relay/v1/messages/{quote(pubsub_topic, safe='')}", json.dumps(message)) + def send_sync_message(self, message): + return self.rest_call("post", "store/v1/messages", json.dumps(message)) + + def send_sync_request(self): + return self.rest_call("post", "store/v1/sync") + def send_relay_auto_message(self, message): return self.rest_call("post", "relay/v1/auto/messages", json.dumps(message)) diff --git a/src/node/waku_node.py b/src/node/waku_node.py index 3c2cad883a8..92f668e0b52 100644 --- a/src/node/waku_node.py +++ b/src/node/waku_node.py @@ -353,6 +353,12 @@ def send_relay_message(self, message, pubsub_topic): def send_relay_auto_message(self, message): return self._api.send_relay_auto_message(message) + def send_sync_message(self, message): + return self._api.send_sync_message(message) + + def request_sync(self): + return self.api.send_sync_request(self) + def send_light_push_message(self, payload): return self._api.send_light_push_message(payload) diff --git a/src/steps/store.py b/src/steps/store.py index 49e43394f05..6cb0c6d33c7 100644 --- a/src/steps/store.py +++ b/src/steps/store.py @@ -137,6 +137,9 @@ def publish_message(self, via="relay", pubsub_topic=None, message=None, message_ delay(message_propagation_delay) return self.message + def trigger_sync(self, sender=None): + sender.request_sync(self) + @retry(stop=stop_after_delay(30), wait=wait_fixed(1), reraise=True) @allure.step def get_messages_from_store_with_retry(self, node): diff --git a/tests/e2e/test_e2e.py b/tests/e2e/test_e2e.py index 11bdff7de15..00bef44fe76 100644 --- a/tests/e2e/test_e2e.py +++ b/tests/e2e/test_e2e.py @@ -518,3 +518,10 @@ def test_store_no_peer_selected(self): logger.debug("Check if node3 can inquiry stored message without stor peer specified") store_response = self.node3.get_store_messages(pubsub_topic=self.test_pubsub_topic, page_size=5, ascending="true", store_v=store_version) assert len(store_response["messages"]) == 2, "Can't find stored message!!" + + def test_sync_trail(self): + self.node1.start(store="true", relay="true", sync="true") + self.node2.start(store="true", relay="false", discv5_bootstrap_node=self.node1.get_enr_uri()) + # ogger.debug(f"publish mesage via store { self.publish_message(sender=self.node1,via ="sync")} ") + + # logger.debug(f"return of sync request {self.node2.request_sync(self)}")