pytest: fix "bad gossip" flake in test_forward_event_notification

If not all nodes are up-to-date with the new blocks, they can reject
announcements:

```
lightningd-4: 2021-02-23T02:02:47.832Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-gossipd: Ignoring future channel_announcment for 124x1x0 (current block 123)
lightningd-4: 2021-02-23T02:02:47.848Z DEBUG   lightningd: Adding block 133: 2d950451211398de9c10bf9df7eb53b385390eca31e306bc8fc1387b53d9f9a2
lightningd-4: 2021-02-23T02:02:47.865Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-gossipd: Bad gossip order: WIRE_CHANNEL_UPDATE before announcement 124x1x0/0
lightningd-4: 2021-02-23T02:02:47.866Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-gossipd: Bad gossip order: WIRE_CHANNEL_UPDATE before announcement 124x1x0/1
```

Technically, this change is not sufficient either, since *gossipd* might
not know about new block yet.  But it makes this case less likely.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-02-24 11:31:14 +10:30
parent f0fa5d1401
commit c6bd87ccab

View File

@ -1187,12 +1187,16 @@ def test_forward_event_notification(node_factory, bitcoind, executor):
{},
{'disconnect': disconnects}])
l1.openchannel(l2, confirm=False)
l2.openchannel(l3, confirm=False)
l2.openchannel(l4, confirm=False)
l2.openchannel(l5, confirm=False)
l1.openchannel(l2, confirm=False, wait_for_announce=False)
l2.openchannel(l3, confirm=False, wait_for_announce=False)
l2.openchannel(l4, confirm=False, wait_for_announce=False)
l2.openchannel(l5, confirm=False, wait_for_announce=False)
# Generate 5, then make sure everyone is up to date before
# last one, otherwise they might think it's in the future!
bitcoind.generate_block(5)
sync_blockheight(bitcoind, [l1, l2, l3, l4, l5])
bitcoind.generate_block(6)
bitcoind.generate_block(1)
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 8)