From 694833acfb632105a4d5ab010edfdbe1dd46bbce Mon Sep 17 00:00:00 2001 From: Aya Hassan Date: Sun, 12 Jul 2026 18:23:19 +0200 Subject: [PATCH] remove the temp test code --- waku/wrapper.py | 66 ------------------------------------------------- 1 file changed, 66 deletions(-) diff --git a/waku/wrapper.py b/waku/wrapper.py index 89cd17f..7a7e128 100644 --- a/waku/wrapper.py +++ b/waku/wrapper.py @@ -520,69 +520,3 @@ class NodeWrapper: return Err(cb_msg.decode("utf-8") if cb_msg else f"channel_close({channel_id}): callback failed (ret={cb_ret})") return Ok(cb_ret) - - -# --------------------------------------------------------------------------- -# TEMPORARY manual smoke test for the channel wrappers. -# Run: python -m waku.wrapper (from the repo root, with lib/liblogosdelivery.so built) -# Remove before merging. -# --------------------------------------------------------------------------- -if __name__ == "__main__": - import base64 - import socket - - def _free_port() -> int: - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - s.bind(("", 0)) - return s.getsockname()[1] - - def _show(label, result): - tag = "OK " if result.is_ok() else "ERR" - value = result.ok_value if result.is_ok() else result.err() - print(f"[{tag}] {label}: {value!r}") - - config = { - "logLevel": "INFO", - "listenAddress": "0.0.0.0", - "tcpPort": _free_port(), - "discv5UdpPort": _free_port(), - "restPort": _free_port(), - "restAddress": "0.0.0.0", - "clusterId": "198", - "relay": True, - "store": False, - "filter": False, - "lightpush": False, - "peerExchange": False, - "discv5Discovery": False, - } - - CHANNEL_ID = "smoke-channel" - CONTENT_TOPIC = "/test/1/channel/proto" - SENDER_ID = "smoke-sender" - - node_result = NodeWrapper.create_and_start(config) - if node_result.is_err(): - print(f"[ERR] create_and_start: {node_result.err()!r}") - raise SystemExit(1) - node = node_result.ok_value - print("[OK ] node created and started") - - try: - # RC01: create, then duplicate create rejected. - _show("channel_create", node.channel_create(CHANNEL_ID, CONTENT_TOPIC, SENDER_ID)) - _show("channel_create (duplicate)", node.channel_create(CHANNEL_ID, CONTENT_TOPIC, SENDER_ID)) - - # RC02: send on unknown channel. - payload = base64.b64encode(b"hello channel").decode("ascii") - _show("channel_send (unknown id)", node.channel_send("no-such-channel", {"payload": payload, "ephemeral": False})) - - # RC04: empty payload rejected; then a valid send returns a handle. - _show("channel_send (empty payload)", node.channel_send(CHANNEL_ID, {"payload": "", "ephemeral": False})) - _show("channel_send", node.channel_send(CHANNEL_ID, {"payload": payload, "ephemeral": False})) - - # RC03: close, then close unknown rejected. - _show("channel_close", node.channel_close(CHANNEL_ID)) - _show("channel_close (unknown id)", node.channel_close(CHANNEL_ID)) - finally: - _show("stop_and_destroy", node.stop_and_destroy())