From aa01a9f88f96ae30f6de6f0026b5a4ee8ea1a348 Mon Sep 17 00:00:00 2001 From: Aya Hassan Date: Sun, 12 Jul 2026 19:21:06 +0200 Subject: [PATCH] adding first test and wrapper --- src/node/wrappers_manager.py | 16 ++++++++++ .../wrappers_tests/test_channel_lifecycle.py | 30 +++++++++++++++++++ vendor/logos-delivery-python-bindings | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/wrappers_tests/test_channel_lifecycle.py 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..d39841361 --- /dev/null +++ b/tests/wrappers_tests/test_channel_lifecycle.py @@ -0,0 +1,30 @@ +import pytest +from src.node.wrappers_manager import WrapperManager + +CHANNEL_ID = "rc01-channel" +CONTENT_TOPIC = "/test/1/channel/proto" +SENDER_ID = "rc01-sender" + + +@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. + """ + create_node_result = WrapperManager.create_and_start(config=node_config) + 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}" + finally: + node.stop_and_destroy() diff --git a/vendor/logos-delivery-python-bindings b/vendor/logos-delivery-python-bindings index 36041dae7..694833acf 160000 --- a/vendor/logos-delivery-python-bindings +++ b/vendor/logos-delivery-python-bindings @@ -1 +1 @@ -Subproject commit 36041dae76a53fff91fe53253933d8eb2ab385f9 +Subproject commit 694833acfb632105a4d5ab010edfdbe1dd46bbce