pytest: make sure node order is stable before querying in test_gossmap_lost_node

The channel vanishes from listchannels when it's dying, *but* only when it gets deleted
do we consider moving the actual node_announcement.  We have to wait until gossipd
has seen the 12 blocks, and move it if necessary.

```
E         Full diff:
E           {
E               'nodes': [
E         -         {
E         -             'addresses': [],
E         -             'alias': 'SILENTARTIST-e986cd2-modded',
E         -             'color': '022d22',
E         -             'features': '808898880a8a59a1',
E         -             'last_timestamp': 1767572731,
E         -             'nodeid': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59',
E         -         },
E                   {
E                       'addresses': [],
E                       'alias': 'HOPPINGFIRE-e986cd2-modded',
E                       'color': '035d2b',
E                       'features': '808898880a8a59a1',
E                       'last_timestamp': 1767572731,
E                       'nodeid': '035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d',
E                   },
E                   {
E                       'addresses': [],
E                       'alias': 'JUNIORFELONY-e986cd2-modded',
E                       'color': '0382ce',
E                       'features': '808898880a8a59a1',
E                       'last_timestamp': 1767572731,
E                       'nodeid': '0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199',
E                   },
E                   {
E                       'addresses': [],
E         +             'alias': 'SILENTARTIST-e986cd2-modded',
E         +             'color': '022d22',
E         +             'features': '808898880a8a59a1',
E         +             'last_timestamp': 1767572731,
E         +             'nodeid': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59',
E         +         },
E         +         {
E         +             'addresses': [],
E                       'alias': 'JUNIORBEAM-e986cd2-modded',
E                       'color': '0266e4',
E                       'features': '808898880a8a59a1',
E                       'last_timestamp': 1767572732,
E                       'nodeid': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518',
E                   },
E               ],
E           }

tests/test_gossip.py:2390: AssertionError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2026-01-07 16:12:29 +10:30
parent 7175001988
commit 082e70aada

View File

@@ -2378,13 +2378,16 @@ def test_gossmap_lost_node(node_factory, bitcoind):
scid23 = only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['short_channel_id']
l2.rpc.close(l3.info['id'])
bitcoind.generate_block(13, wait_for_mempool=1)
wait_for(lambda: l1.rpc.listchannels(scid23) == {'channels': []})
# Order of nodes is not stable.
sync_blockheight(bitcoind, [l1])
assert l1.rpc.listchannels(scid23) == {'channels': []}
pre_channels = l1.rpc.listchannels()
pre_nodes = l1.rpc.listnodes()
pre_nodes = sorted(l1.rpc.listnodes()['nodes'], key=lambda n: n['nodeid'])
l1.restart()
post_channels = l1.rpc.listchannels()
post_nodes = l1.rpc.listnodes()
post_nodes = sorted(l1.rpc.listnodes()['nodes'], key=lambda n: n['nodeid'])
assert post_channels == pre_channels
assert post_nodes == pre_nodes