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 <rusty@rustcorp.com.au>
Fixes: #5403
This commit is contained in:
Rusty Russell 2022-07-12 14:14:36 +09:30
parent ddf8fbdb5d
commit 06e1e119aa
2 changed files with 15 additions and 2 deletions

View file

@ -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);

View file

@ -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,