From 06e1e119aa0633a9257dbfefe65a04082df488c0 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 12 Jul 2022 14:14:36 +0930 Subject: [PATCH] pytest: fix test_gossip_no_empty_announcements flake. This is a side-effect of fixing aging: sometimes, we age our rcvd_filter cache too fast, and thus re-xmit. This breaks our test, since it used dev-disconnect on the channel_announce, but that closes to l3, not l1! ``` > assert l1.rpc.listchannels()['channels'] == [] E AssertionError: assert [{'active': T...ags': 1, ...}] == [] E Left contains 2 more items, first extra item: {'active': True, 'amount_msat': 100000000msat, 'base_fee_millisatoshi': 1, 'channel_flags': 0, ...} ``` Signed-off-by: Rusty Russell Fixes: #5403 --- connectd/multiplex.c | 15 ++++++++++++++- tests/test_gossip.py | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/connectd/multiplex.c b/connectd/multiplex.c index 0db695990..f9d41bcae 100644 --- a/connectd/multiplex.c +++ b/connectd/multiplex.c @@ -344,8 +344,21 @@ static struct io_plan *encrypt_and_send(struct peer *peer, /* Kicks off write_to_peer() to look for more gossip to send from store */ static void wake_gossip(struct peer *peer) { + bool flush_gossip_filter = true; + +#if DEVELOPER + /* With dev-fast-gossip, we clean every 2 seconds, which is too + * fast for our slow tests! So we only call this one time in 5 + * actually twice that, as it's not per-peer! */ + static int gossip_age_count; + + if (peer->daemon->dev_fast_gossip && gossip_age_count++ % 5 != 0) + flush_gossip_filter = false; +#endif + /* Don't remember sent per-peer gossip forever. */ - gossip_rcvd_filter_age(peer->gs.grf); + if (flush_gossip_filter) + gossip_rcvd_filter_age(peer->gs.grf); peer->gs.active = IFDEV(!peer->daemon->dev_suppress_gossip, true); io_wake(peer->peer_outq); diff --git a/tests/test_gossip.py b/tests/test_gossip.py index eabfdb96e..0850f8a81 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -622,10 +622,10 @@ def test_gossip_no_empty_announcements(node_factory, bitcoind, chainparams): # l2 sends CHANNEL_ANNOUNCEMENT to l1, then disconnects/ l2.daemon.wait_for_log('dev_disconnect') l1.daemon.wait_for_log(r'\[IN\] 0100') + wait_for(lambda: l1.rpc.listchannels()['channels'] == []) # l1 won't relay it (make sure it has time to digest though) time.sleep(2) - assert l1.rpc.listchannels()['channels'] == [] encoded = subprocess.run(['devtools/mkencoded', '--scids', '00'], check=True, timeout=TIMEOUT,