From 692b2a7133b9bc8d334294efe2e5fc2fb5c40e3f Mon Sep 17 00:00:00 2001 From: Aya Hassan Date: Sun, 26 Jul 2026 21:59:17 +0200 Subject: [PATCH] Adding RC07 --- tests/wrappers_tests/test_channel_delivery.py | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/wrappers_tests/test_channel_delivery.py b/tests/wrappers_tests/test_channel_delivery.py index 8b1ad1563..bd5b16aca 100644 --- a/tests/wrappers_tests/test_channel_delivery.py +++ b/tests/wrappers_tests/test_channel_delivery.py @@ -22,6 +22,10 @@ MESSAGE_RECEIVED_EVENT = "message_received" RC06_CHANNEL_ID = "rc06-channel" RC06_CONTENT_TOPIC = "/test/1/rc06-channel/proto" +RC07_CHANNEL_ID = "rc07-channel" +RC07_CONTENT_TOPIC = "/test/1/rc07-channel/proto" +RC07_OTHER_CONTENT_TOPIC = "/test/1/rc07-other/proto" + CLOSED_CHANNEL_ID = "rc-closed-channel" CLOSED_CONTENT_TOPIC = "/test/1/rc-closed-channel/proto" @@ -184,6 +188,60 @@ class TestChannelDelivery: leaked = wait_for_channel_received(receiver_collector, RC06_CHANNEL_ID, NO_CHANNEL_DELIVERY_WINDOW_S) assert leaked is None, f"an unmarked message must not surface as a {CHANNEL_RECEIVED_EVENT}; got: {leaked!r}" + def test_rc07_wrong_content_topic_dropped(self, node_config): + """RC07: a correctly-marked channel message published on a different + content topic is dropped at channel ingress. + + A runs the same channelId as B but on RC07_OTHER_CONTENT_TOPIC. B is + subscribed to that topic too, so B's messaging layer still surfaces the + message (message_received), proving it arrived, but B's channel is bound + to RC07_CONTENT_TOPIC and must not fire channel_message_received. + """ + payload_b64 = to_base64("rc07 message on the wrong content topic") + + node_config.update( + { + "relay": True, + "reliabilityEnabled": False, + "numShardsInNetwork": 1, + } + ) + + receiver_collector = EventCollector() + receiver_result = WrapperManager.create_and_start(config=node_config, event_cb=receiver_collector.event_callback) + assert receiver_result.is_ok(), f"Failed to start receiver: {receiver_result.err()}" + + with receiver_result.ok_value as receiver: + sender_config = { + **node_config, + "staticnodes": [get_node_multiaddr(receiver)], + "portsShift": 1, + } + + for content_topic in (RC07_CONTENT_TOPIC, RC07_OTHER_CONTENT_TOPIC): + subscribe_result = receiver.subscribe_content_topic(content_topic) + assert subscribe_result.is_ok(), f"receiver subscribe_content_topic {content_topic} failed: {subscribe_result.err()}" + + receiver_create = receiver.channel_create(RC07_CHANNEL_ID, RC07_CONTENT_TOPIC, SENDER_B) + assert receiver_create.is_ok(), f"receiver channel_create failed: {receiver_create.err()}" + + with ChannelSenderProcess( + sender_config, + content_topic=RC07_OTHER_CONTENT_TOPIC, + channel_id=RC07_CHANNEL_ID, + sender_id=SENDER_A, + payload_b64=payload_b64, + settle_s=MESH_SETTLE_S, + ): + arrived = wait_for_message_received(receiver_collector, RC07_OTHER_CONTENT_TOPIC, DELIVERY_TIMEOUT_S) + assert arrived is not None, ( + f"receiver never saw a {MESSAGE_RECEIVED_EVENT} for {RC07_OTHER_CONTENT_TOPIC} within {DELIVERY_TIMEOUT_S}s; " + f"cannot conclude the channel dropped it. Collected events: {receiver_collector.snapshot()}" + ) + + leaked = wait_for_channel_received(receiver_collector, RC07_CHANNEL_ID, NO_CHANNEL_DELIVERY_WINDOW_S) + assert leaked is None, f"a message on a foreign content topic must not surface as a {CHANNEL_RECEIVED_EVENT}; got: {leaked!r}" + def test_receive_after_close_emits_no_channel_event(self, node_config): """A closed channel must not deliver: B closes its channel, then A sends a valid channel message on the same channel + content topic.