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

Function test_ping

tests/test_misc.py:354–385  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

352
353
354def test_ping(node_factory):
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)
386
387
388def test_htlc_sig_persistence(node_factory, bitcoind, executor, chainparams):

Callers

nothing calls this directly

Calls 2

ping_testsFunction · 0.85
line_graphMethod · 0.80

Tested by

no test coverage detected