MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_tracing_socket

Function test_tracing_socket

tests/test_misc.py:5296–5333  ·  view source on GitHub ↗

Test UDS datagram tracing backend via CLN_TRACE_SOCKET.

(node_factory)

Source from the content-addressed store, hash-verified

5294
5295
5296def test_tracing_socket(node_factory):
5297 """Test UDS datagram tracing backend via CLN_TRACE_SOCKET."""
5298 l1 = node_factory.get_node(start=False)
5299 sock_path = os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "trace.sock")
5300
5301 # Create a SOCK_DGRAM UDS listener
5302 sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
5303 sock.bind(sock_path)
5304 sock.settimeout(5)
5305
5306 l1.daemon.env["CLN_TRACE_SOCKET"] = sock_path
5307 l1.start()
5308 l1.stop()
5309
5310 # Collect all datagrams that were sent
5311 spans = []
5312 while True:
5313 try:
5314 data = sock.recv(4096)
5315 spans.append(json.loads(data.decode("utf-8")))
5316 except socket.timeout:
5317 break
5318
5319 sock.close()
5320
5321 # We should have received at least some spans from startup
5322 assert len(spans) > 0, "No spans received via UDS socket"
5323
5324 for span_array in spans:
5325 # Each datagram is a Zipkin JSON array with one span
5326 assert isinstance(span_array, list)
5327 assert len(span_array) == 1
5328 span = span_array[0]
5329
5330 # Validate required Zipkin fields are present
5331 for key in ("id", "name", "timestamp", "duration", "traceId"):
5332 assert key in span, f"Missing key {key} in span {span}"
5333 assert span["localEndpoint"] == {"serviceName": "lightningd"}

Callers

nothing calls this directly

Calls 7

joinMethod · 0.80
get_nodeMethod · 0.45
startMethod · 0.45
stopMethod · 0.45
recvMethod · 0.45
decodeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected