MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_node_reannounce

Function test_node_reannounce

tests/test_gossip.py:1260–1342  ·  view source on GitHub ↗

Test that we reannounce a node when parameters change

(node_factory, bitcoind, chainparams)

Source from the content-addressed store, hash-verified

1258@pytest.mark.openchannel('v1')
1259@pytest.mark.openchannel('v2')
1260def test_node_reannounce(node_factory, bitcoind, chainparams):
1261 "Test that we reannounce a node when parameters change"
1262 l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True,
1263 'log-level': 'io'})
1264 bitcoind.generate_block(5)
1265 genesis_blockhash = chainparams['chain_hash']
1266
1267 # Wait for node_announcement for l1.
1268 l2.daemon.wait_for_log(r'\[IN\] 0101.*{}'.format(l1.info['id']))
1269 # Wait for it to process it.
1270 wait_for(lambda: l2.rpc.listnodes(l1.info['id'])['nodes'] != [])
1271 wait_for(lambda: 'alias' in only_one(l2.rpc.listnodes(l1.info['id'])['nodes']))
1272 assert only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['alias'].startswith('JUNIORBEAM')
1273
1274 lfeatures = expected_node_features()
1275 if l1.config('experimental-dual-fund'):
1276 lfeatures = expected_node_features(extra=[21, 29])
1277
1278 # Make sure it gets features correct.
1279 assert only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['features'] == lfeatures
1280
1281 l1.stop()
1282 l1.daemon.opts['alias'] = 'SENIORBEAM'
1283 # It won't update within 5 seconds, so sleep.
1284 time.sleep(5)
1285 l1.start()
1286
1287 wait_for(lambda: only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['alias'] == 'SENIORBEAM')
1288
1289 # Get node_announcements.
1290 msgs = l1.query_gossip('gossip_timestamp_filter',
1291 genesis_blockhash,
1292 '0', '0xFFFFFFFF',
1293 # Filter out gossip_timestamp_filter,
1294 # channel_announcement and channel_updates.
1295 # And pings.
1296 filters=['0109', '0107', '0102', '0100', '0012'])
1297
1298 # May send its own announcement *twice*, since it always spams us.
1299 msgs = list(set(msgs))
1300 assert len(msgs) == 2
1301 assert (bytes("SENIORBEAM", encoding="utf8").hex() in msgs[0]
1302 or bytes("SENIORBEAM", encoding="utf8").hex() in msgs[1])
1303
1304 # Restart should re-xmit exact same update on reconnect!
1305 l1.restart()
1306
1307 msgs2 = l1.query_gossip('gossip_timestamp_filter',
1308 genesis_blockhash,
1309 '0', '0xFFFFFFFF',
1310 # Filter out gossip_timestamp_filter,
1311 # channel_announcement and channel_updates.
1312 # And pings.
1313 filters=['0109', '0107', '0102', '0100', '0012'])
1314
1315 # May send its own announcement *twice*, since it always spams us.
1316 assert set(msgs) == set(msgs2)
1317 # Won't have queued up another one, either.

Callers

nothing calls this directly

Calls 15

wait_forFunction · 0.90
only_oneFunction · 0.90
expected_node_featuresFunction · 0.90
MillisatoshiClass · 0.90
line_graphMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
configMethod · 0.80
query_gossipMethod · 0.80
restartMethod · 0.80
is_in_logMethod · 0.80
listnodesMethod · 0.45

Tested by

no test coverage detected