diff --git a/tests/test_connection.py b/tests/test_connection.py index 9b152bb44..1118bea51 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -4846,6 +4846,41 @@ def test_no_delay(node_factory): assert end < start + 100 * 0.5 +@unittest.skipIf(os.getenv('TEST_BENCH', '0') == '0', "For profiling") +def test_bench(node_factory): + """Is our Nagle disabling for critical messages working?""" + l1, l2 = node_factory.get_nodes(2, opts={'start': False, + 'commit-time': 0}) + + # memleak detection plays havoc with profiles. + del l1.daemon.env["LIGHTNINGD_DEV_MEMLEAK"] + del l2.daemon.env["LIGHTNINGD_DEV_MEMLEAK"] + + l1.start() + l2.start() + node_factory.join_nodes([l1, l2]) + + scid = only_one(l1.rpc.listpeerchannels()['channels'])['short_channel_id'] + routestep = { + 'amount_msat': 100, + 'id': l2.info['id'], + 'delay': 5, + 'channel': scid + } + + start = time.time() + # If we were stupid enough to leave Nagle enabled, this would add 200ms + # seconds delays each way! + for _ in range(1000): + phash = random.randbytes(32).hex() + l1.rpc.sendpay([routestep], phash) + with pytest.raises(RpcError, match="WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS"): + l1.rpc.waitsendpay(phash) + end = time.time() + duration = end - start + assert duration == 0 + + def test_listpeerchannels_by_scid(node_factory): l1, l2, l3 = node_factory.line_graph(3, announce_channels=False)