From 2348944a1308aa70e1bbbfb45d650cbbb14e90fb Mon Sep 17 00:00:00 2001 From: Darshan <35736874+darshankabariya@users.noreply.github.com> Date: Tue, 14 Jul 2026 22:16:01 +0530 Subject: [PATCH 1/2] fix: adapt lightpush and filter tests to new nwaku default rate limits (#198) --- tests/filter/test_subscribe_create.py | 14 ++++++-------- tests/light_push/test_publish.py | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/filter/test_subscribe_create.py b/tests/filter/test_subscribe_create.py index 4dcac4f2d..7481a074e 100644 --- a/tests/filter/test_subscribe_create.py +++ b/tests/filter/test_subscribe_create.py @@ -63,7 +63,7 @@ class TestFilterSubscribeCreate(StepsFilter): assert not failed_content_topics, f"ContentTopics failed: {failed_content_topics}" def test_filter_subscribe_to_29_content_topics_in_separate_calls(self, subscribe_main_nodes): - # subscribe_main_nodes already consumed 1 slot; make 29 more = 30 total, all must succeed + # subscribe_main_nodes already made 1 subscribe call; make 29 more = 30 total, all must succeed _29_content_topics = [str(i) for i in range(29)] for content_topic in _29_content_topics: self.create_filter_subscription({"requestId": str(uuid4()), "contentFilters": [content_topic], "pubsubTopic": self.test_pubsub_topic}) @@ -77,8 +77,8 @@ class TestFilterSubscribeCreate(StepsFilter): logger.error(f"ContentTopic {content_topic} failed: {str(ex)}") failed_content_topics.append(content_topic) assert not failed_content_topics, f"ContentTopics failed: {failed_content_topics}" - # Rate limit is a token bucket (30/min); keep calling beyond 30 until one is denied - rate_limited = False + # Default rate limit is filter:100/1s; sequential calls stay under it, so calls beyond 30 must succeed + failed_extra_calls = [] for extra in range(1, 20): try: self.create_filter_subscription( @@ -86,11 +86,9 @@ class TestFilterSubscribeCreate(StepsFilter): ) logger.debug(f"Extra subscribe call #{extra} succeeded") except Exception as ex: - assert "subscription failed" in str(ex) or "rate limit exceeded" in str(ex), f"Unexpected error on extra call #{extra}: {ex}" - logger.info(f"Rate limit hit on extra call #{extra}: {ex}") - rate_limited = True - break - assert rate_limited, "Rate limit was not triggered on any call beyond 30" + logger.error(f"Extra subscribe call #{extra} failed: {ex}") + failed_extra_calls.append(extra) + assert not failed_extra_calls, f"Subscribe calls beyond 30 were rate limited: {failed_extra_calls}" def test_filter_subscribe_to_101_content_topics(self, subscribe_main_nodes): try: diff --git a/tests/light_push/test_publish.py b/tests/light_push/test_publish.py index 62d905c7a..841715396 100644 --- a/tests/light_push/test_publish.py +++ b/tests/light_push/test_publish.py @@ -29,6 +29,7 @@ class TestLightPushPublish(StepsLightPush): failed_payloads = [] for payload in SAMPLE_INPUTS: logger.debug(f'Running test with payload {payload["description"]}') + delay(0.5) message = self.create_message(payload=to_base64(payload["value"])) try: self.check_light_pushed_message_reaches_receiving_peer(message=message) @@ -88,6 +89,7 @@ class TestLightPushPublish(StepsLightPush): failed_content_topics = [] for content_topic in SAMPLE_INPUTS: logger.debug(f'Running test with content topic {content_topic["description"]}') + delay(0.5) message = self.create_message(contentTopic=content_topic["value"]) try: self.check_light_pushed_message_reaches_receiving_peer(message=message) From 27469663ac0509df336c489687b6ac04ddad5463 Mon Sep 17 00:00:00 2001 From: AYAHASSAN287 <49167455+AYAHASSAN287@users.noreply.github.com> Date: Tue, 14 Jul 2026 20:39:09 +0300 Subject: [PATCH 2/2] Channel API RC01-RC02 (#197) * adding first test and wrapper * add mode core , ignore generated files * added test RC02 --- .gitignore | 3 + src/node/wrappers_manager.py | 16 +++++ .../wrappers_tests/test_channel_lifecycle.py | 59 +++++++++++++++++++ vendor/logos-delivery-python-bindings | 2 +- 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 tests/wrappers_tests/test_channel_lifecycle.py diff --git a/.gitignore b/.gitignore index 7d7cfc8b6..dff4b9035 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,6 @@ dmypy.json # Waku node runtime artifacts store.sqlite3* + +# SDS / reliable channel manager generated files +data/ diff --git a/src/node/wrappers_manager.py b/src/node/wrappers_manager.py index 2a0e84982..8b59bcb4f 100644 --- a/src/node/wrappers_manager.py +++ b/src/node/wrappers_manager.py @@ -75,6 +75,22 @@ class WrapperManager: def send_message(self, message: dict, *, timeout_s: float = 20.0) -> Result[str, str]: return self._node.send_message(message, timeout_s=timeout_s) + def channel_create( + self, + channel_id: str, + content_topic: str, + sender_id: str, + *, + timeout_s: float = 20.0, + ) -> Result[str, str]: + return self._node.channel_create(channel_id, content_topic, sender_id, timeout_s=timeout_s) + + def channel_send(self, channel_id: str, message: dict, *, timeout_s: float = 20.0) -> Result[str, str]: + return self._node.channel_send(channel_id, message, timeout_s=timeout_s) + + def channel_close(self, channel_id: str, *, timeout_s: float = 20.0) -> Result[int, str]: + return self._node.channel_close(channel_id, timeout_s=timeout_s) + def get_available_node_info_ids(self, *, timeout_s: float = 20.0) -> Result[list[str], str]: return self._node.get_available_node_info_ids(timeout_s=timeout_s) diff --git a/tests/wrappers_tests/test_channel_lifecycle.py b/tests/wrappers_tests/test_channel_lifecycle.py new file mode 100644 index 000000000..5f9beee40 --- /dev/null +++ b/tests/wrappers_tests/test_channel_lifecycle.py @@ -0,0 +1,59 @@ +import pytest +from src.node.wrappers_manager import WrapperManager +from src.node.wrapper_helpers import EventCollector, create_message_bindings + +CHANNEL_ID = "rc01-channel" +CONTENT_TOPIC = "/test/1/channel/proto" +SENDER_ID = "rc01-sender" + +UNKNOWN_CHANNEL_ID = "rc02-unknown-channel" + + +@pytest.mark.smoke +class TestChannelLifecycle: + def test_rc01_create_channel_duplicate_rejected(self, node_config): + """RC01: create a channel; a duplicate create with the same id is rejected. + + The reliable channel manager is mounted automatically for a Core-mode + node, so no store / --reliability is needed. No events are expected. + """ + node_config.update({"mode": "Core"}) + + collector = EventCollector() + create_node_result = WrapperManager.create_and_start(config=node_config, event_cb=collector.event_callback) + assert create_node_result.is_ok(), f"Failed to create and start node: {create_node_result.err()}" + node = create_node_result.ok_value + + try: + create_result = node.channel_create(CHANNEL_ID, CONTENT_TOPIC, SENDER_ID) + assert create_result.is_ok(), f"channel_create failed: {create_result.err()}" + assert create_result.ok_value == CHANNEL_ID, f"channel_create returned unexpected id: {create_result.ok_value!r}" + + duplicate_result = node.channel_create(CHANNEL_ID, CONTENT_TOPIC, SENDER_ID) + assert duplicate_result.is_err(), f"duplicate channel_create must fail, got Ok({duplicate_result.ok_value!r})" + assert f"channel already exists: {CHANNEL_ID}" in duplicate_result.err(), f"unexpected error message: {duplicate_result.err()!r}" + + assert collector.events == [], f"expected no events, got: {collector.events}" + finally: + node.stop_and_destroy() + + def test_rc02_send_on_unknown_channel_rejected(self, node_config): + """RC02: channel_send() to an id that was never created is rejected. + + The send must Err with "unknown channel: " and emit no events. + """ + node_config.update({"mode": "Core"}) + + collector = EventCollector() + create_node_result = WrapperManager.create_and_start(config=node_config, event_cb=collector.event_callback) + assert create_node_result.is_ok(), f"Failed to create and start node: {create_node_result.err()}" + node = create_node_result.ok_value + + try: + send_result = node.channel_send(UNKNOWN_CHANNEL_ID, create_message_bindings()) + assert send_result.is_err(), f"channel_send on unknown channel must fail, got Ok({send_result.ok_value!r})" + assert f"unknown channel: {UNKNOWN_CHANNEL_ID}" in send_result.err(), f"unexpected error message: {send_result.err()!r}" + + assert collector.events == [], f"expected no events, got: {collector.events}" + finally: + node.stop_and_destroy() diff --git a/vendor/logos-delivery-python-bindings b/vendor/logos-delivery-python-bindings index 36041dae7..5fb251bd8 160000 --- a/vendor/logos-delivery-python-bindings +++ b/vendor/logos-delivery-python-bindings @@ -1 +1 @@ -Subproject commit 36041dae76a53fff91fe53253933d8eb2ab385f9 +Subproject commit 5fb251bd8c6cae40e36a59874d5bc747f52230bd