Skip to content

Commit 863aac4

Browse files
committed
pytest: test for lack of nagle delay.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 4ba7fab commit 863aac4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_connection.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4822,6 +4822,31 @@ def test_private_channel_no_reconnect(node_factory):
48224822
assert only_one(l1.rpc.listpeers()['peers'])['connected'] is False
48234823

48244824

4825+
@pytest.mark.xfail(strict=True)
4826+
@unittest.skipIf(VALGRIND, "We assume machine is reasonably fast")
4827+
def test_no_delay(node_factory):
4828+
"""Is our Nagle disabling for critical messages working?"""
4829+
l1, l2 = node_factory.line_graph(2)
4830+
4831+
scid = only_one(l1.rpc.listpeerchannels()['channels'])['short_channel_id']
4832+
routestep = {
4833+
'amount_msat': 100,
4834+
'id': l2.info['id'],
4835+
'delay': 5,
4836+
'channel': scid
4837+
}
4838+
start = time.time()
4839+
# If we were stupid enough to leave Nagle enabled, this would add 200ms
4840+
# seconds delays each way!
4841+
for _ in range(100):
4842+
phash = random.randbytes(32).hex()
4843+
l1.rpc.sendpay([routestep], phash)
4844+
with pytest.raises(RpcError, match="WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS"):
4845+
l1.rpc.waitsendpay(phash)
4846+
end = time.time()
4847+
assert end < start + 100 * 0.5
4848+
4849+
48254850
def test_listpeerchannels_by_scid(node_factory):
48264851
l1, l2, l3 = node_factory.line_graph(3, announce_channels=False)
48274852

0 commit comments

Comments
 (0)