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

Function ping_tests

tests/test_misc.py:357–382  ·  view source on GitHub ↗
(l1, l2)

Source from the content-addressed store, hash-verified

355 l1, l2 = node_factory.line_graph(2)
356
357 def ping_tests(l1, l2):
358 # 0-byte pong gives just type + length field.
359 ret = l1.rpc.ping(l2.info['id'], 0, 0)
360 assert ret['totlen'] == 4
361
362 # 1000-byte ping, 0-byte pong.
363 ret = l1.rpc.ping(l2.info['id'], 1000, 0)
364 assert ret['totlen'] == 4
365
366 # 1000 byte pong.
367 ret = l1.rpc.ping(l2.info['id'], 1000, 1000)
368 assert ret['totlen'] == 1004
369
370 # Maximum length pong.
371 ret = l1.rpc.ping(l2.info['id'], 1000, 65531)
372 assert ret['totlen'] == 65535
373
374 # Overlength -> no reply.
375 for s in range(65532, 65536):
376 ret = l1.rpc.ping(l2.info['id'], 1000, s)
377 assert ret['totlen'] == 0
378
379 # 65535 - type(2 bytes) - num_pong_bytes(2 bytes) - byteslen(2 bytes)
380 # = 65529 max.
381 with pytest.raises(RpcError, match=r'oversize ping'):
382 l1.rpc.ping(l2.info['id'], 65530, 1)
383
384 # channeld pinging
385 ping_tests(l1, l2)

Callers 1

test_pingFunction · 0.85

Calls 1

pingMethod · 0.45

Tested by

no test coverage detected