From 17e727b5d444783c02cf8191b01f267048a24bfd Mon Sep 17 00:00:00 2001 From: Kyle Santiago Date: Sat, 17 Oct 2026 17:00:41 -0400 Subject: [PATCH 1/2] pytest: check test_gossip_throttle's throttling in the log, not by a 3s floor --- tests/test_gossip.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 5df2f020471e..b00f0cc08f2b 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -2205,7 +2205,10 @@ def test_gossip_throttle(node_factory, bitcoind, chainparams): check=True, timeout=TIMEOUT, stdout=subprocess.PIPE).stdout.split() time_slow = time.time() - start_slow - assert time_slow > 3 + # A throttle waits at least a second; how many it takes depends on + # message sizes and the random flush delay, so check the log for it. + assert time_slow > 1 + l4.daemon.wait_for_log('Throttling outgoing peer .*: too much traffic') # Contents should be identical (once uniquified, since each # doubles-up on its own gossip) @@ -2257,7 +2260,8 @@ def test_gossip_throttle(node_factory, bitcoind, chainparams): check=True, timeout=TIMEOUT, stdout=subprocess.PIPE).stdout.split() time_slow = time.time() - start_slow - assert time_slow > 3 + assert time_slow > 1 + l4.daemon.wait_for_log('Throttling outgoing peer .*: too much traffic') assert set(out2) == set(out4) From 469349afbfe27b31a2361a6062f9b26e15b1ae22 Mon Sep 17 00:00:00 2001 From: Kyle Santiago Date: Sat, 17 Oct 2026 17:43:39 -0400 Subject: [PATCH 2/2] pytest: match test_gossip_throttle's throttle by gossipwith's id, either reason --- tests/test_gossip.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_gossip.py b/tests/test_gossip.py index b00f0cc08f2b..f7c773167e8f 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -2168,6 +2168,10 @@ def test_dump_own_gossip(node_factory): assert expect == [] +# devtools/gossipwith's node id, from its default secret. +GOSSIPWITH_ID = '0324653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c' + + def test_gossip_throttle(node_factory, bitcoind, chainparams): """Make some gossip, test it gets throttled""" l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True, @@ -2207,8 +2211,11 @@ def test_gossip_throttle(node_factory, bitcoind, chainparams): time_slow = time.time() - start_slow # A throttle waits at least a second; how many it takes depends on # message sizes and the random flush delay, so check the log for it. + # It is logged once per connection, with whichever of traffic or CPU + # went over first. gossipwith always uses the same key, so its id + # tells its throttles from l3's. assert time_slow > 1 - l4.daemon.wait_for_log('Throttling outgoing peer .*: too much traffic') + l4.daemon.wait_for_log(r'Throttling outgoing peer {}: too much'.format(GOSSIPWITH_ID)) # Contents should be identical (once uniquified, since each # doubles-up on its own gossip) @@ -2261,7 +2268,7 @@ def test_gossip_throttle(node_factory, bitcoind, chainparams): timeout=TIMEOUT, stdout=subprocess.PIPE).stdout.split() time_slow = time.time() - start_slow assert time_slow > 1 - l4.daemon.wait_for_log('Throttling outgoing peer .*: too much traffic') + l4.daemon.wait_for_log(r'Throttling outgoing peer {}: too much'.format(GOSSIPWITH_ID)) assert set(out2) == set(out4)