Skip to content

Commit 6c347a4

Browse files
committed
pytest: fix flake in test_gossip_pruning
We actually pruned before we got all the channels. Extend the pruning time, which unfortunately makes the test slower. ``` 2024-11-18T02:13:11.7013278Z node_factory = <pyln.testing.utils.NodeFactory object at 0x7ff72969e820> 2024-11-18T02:13:11.7014386Z bitcoind = <pyln.testing.utils.BitcoinD object at 0x7ff72968fe20> 2024-11-18T02:13:11.7014996Z 2024-11-18T02:13:11.7015271Z def test_gossip_pruning(node_factory, bitcoind): 2024-11-18T02:13:11.7016222Z """ Create channel and see it being updated in time before pruning 2024-11-18T02:13:11.7017037Z """ 2024-11-18T02:13:11.7017871Z l1, l2, l3 = node_factory.get_nodes(3, opts={'dev-fast-gossip-prune': None, 2024-11-18T02:13:11.7018971Z 'allow_bad_gossip': True}) 2024-11-18T02:13:11.7019634Z 2024-11-18T02:13:11.7020236Z l1.rpc.connect(l2.info['id'], 'localhost', l2.port) 2024-11-18T02:13:11.7021153Z l2.rpc.connect(l3.info['id'], 'localhost', l3.port) 2024-11-18T02:13:11.7021806Z 2024-11-18T02:13:11.7022226Z scid1, _ = l1.fundchannel(l2, 10**6) 2024-11-18T02:13:11.7022886Z scid2, _ = l2.fundchannel(l3, 10**6) 2024-11-18T02:13:11.7023458Z 2024-11-18T02:13:11.7023907Z mine_funding_to_announce(bitcoind, [l1, l2, l3]) 2024-11-18T02:13:11.7025183Z l1_initial_cupdate_timestamp = only_one(l1.rpc.listchannels(source=l1.info['id'])['channels'])['last_update'] 2024-11-18T02:13:11.7026179Z 2024-11-18T02:13:11.7027358Z # Get timestamps of initial updates, so we can ensure they change. 2024-11-18T02:13:11.7028171Z # Channels should be activated locally 2024-11-18T02:13:11.7029326Z > wait_for(lambda: [c['active'] for c in l1.rpc.listchannels()['channels']] == [True] * 4) ``` We can see in logs, it actually started pruning already: ``` 2024-11-18T02:13:11.9622477Z lightningd-1 2024-11-18T01:52:03.570Z DEBUG gossipd: Pruning channel 105x1x0 from network view (ages 1731894723 and 0) ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent 79d39e0 commit 6c347a4

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

common/gossip_constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ enum query_option_flags {
8282
* - MAY ignore the channel.
8383
*/
8484
#define GOSSIP_PRUNE_INTERVAL(dev_fast_gossip_prune_flag) \
85-
DEV_FAST_GOSSIP(dev_fast_gossip_prune_flag, 60, 1209600)
85+
DEV_FAST_GOSSIP(dev_fast_gossip_prune_flag, 120, 1209600)
8686

8787
/* How long after seeing lockin until we announce the channel. */
8888
#define GOSSIP_ANNOUNCE_DELAY(dev_fast_gossip_flag) \

lightningd/options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ static void dev_register_opts(struct lightningd *ld)
860860
clnopt_noarg("--dev-fast-gossip-prune", OPT_DEV,
861861
opt_set_bool,
862862
&ld->dev_fast_gossip_prune,
863-
"Make gossip pruning 30 seconds");
863+
"Make gossip pruning 120 seconds");
864864
clnopt_witharg("--dev-gossip-time", OPT_DEV|OPT_SHOWINT,
865865
opt_set_u32, opt_show_u32,
866866
&ld->dev_gossip_time,

tests/test_gossip.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ def test_gossip_pruning(node_factory, bitcoind):
4747
wait_for(lambda: [c['active'] for c in l2.rpc.listchannels()['channels']] == [True] * 4)
4848
wait_for(lambda: [c['active'] for c in l3.rpc.listchannels()['channels']] == [True] * 4)
4949

50-
# All of them should send a keepalive message (after 30 seconds)
50+
# All of them should send a keepalive message (after 120-30 seconds)
5151
l1.daemon.wait_for_logs([
5252
'Sending keepalive channel_update for {}'.format(scid1),
53-
], timeout=50)
53+
], timeout=100)
5454
l2.daemon.wait_for_logs([
5555
'Sending keepalive channel_update for {}'.format(scid1),
5656
'Sending keepalive channel_update for {}'.format(scid2),
@@ -66,9 +66,9 @@ def test_gossip_pruning(node_factory, bitcoind):
6666
# Now kill l2, so that l1 and l3 will prune from their view after 60 seconds
6767
l2.stop()
6868

69-
# We check every 60/4 seconds, and takes 60 seconds since last update.
69+
# We check every 120/4 seconds, and takes 120 seconds since last update.
7070
l1.daemon.wait_for_log("Pruning channel {} from network view".format(scid2),
71-
timeout=80)
71+
timeout=150)
7272
l3.daemon.wait_for_log("Pruning channel {} from network view".format(scid1))
7373

7474
assert scid2 not in [c['short_channel_id'] for c in l1.rpc.listchannels()['channels']]
@@ -2310,10 +2310,10 @@ def test_gossip_force_broadcast_channel_msgs(node_factory, bitcoind):
23102310
'--hex',
23112311
'--network={}'.format(TEST_NETWORK),
23122312
'--max-messages={}'.format(7),
2313-
'--timeout-after={}'.format(30),
2313+
'--timeout-after={}'.format(120),
23142314
'{}@localhost:{}'.format(l1.info['id'], l1.port)],
23152315
check=True,
2316-
timeout=30 + TIMEOUT, stdout=subprocess.PIPE).stdout.decode('utf-8').split()
2316+
timeout=120 + TIMEOUT, stdout=subprocess.PIPE).stdout.decode('utf-8').split()
23172317

23182318
tally = {key: 0 for key in types.values()}
23192319
for l in lines:

0 commit comments

Comments
 (0)