Test that we reannounce a node when parameters change
(node_factory, bitcoind, chainparams)
| 1312 | @pytest.mark.openchannel('v1') |
| 1313 | @pytest.mark.openchannel('v2') |
| 1314 | def test_node_reannounce(node_factory, bitcoind, chainparams): |
| 1315 | "Test that we reannounce a node when parameters change" |
| 1316 | l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True, |
| 1317 | 'log-level': 'io'}) |
| 1318 | bitcoind.generate_block(5) |
| 1319 | genesis_blockhash = chainparams['chain_hash'] |
| 1320 | |
| 1321 | # Wait for node_announcement for l1. |
| 1322 | l2.daemon.wait_for_log(r'\[IN\] 0101.*{}'.format(l1.info['id'])) |
| 1323 | # Wait for it to process it. |
| 1324 | wait_for(lambda: l2.rpc.listnodes(l1.info['id'])['nodes'] != []) |
| 1325 | wait_for(lambda: 'alias' in only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])) |
| 1326 | assert only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['alias'].startswith('STRANGEBOUNCE') |
| 1327 | |
| 1328 | # Make sure it gets features correct. |
| 1329 | assert only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['features'] == expected_node_features() |
| 1330 | |
| 1331 | l1.stop() |
| 1332 | l1.daemon.opts['alias'] = 'SENIORBEAM' |
| 1333 | # It won't update within 5 seconds, so sleep. |
| 1334 | time.sleep(5) |
| 1335 | l1.start() |
| 1336 | |
| 1337 | wait_for(lambda: only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['alias'] == 'SENIORBEAM') |
| 1338 | |
| 1339 | # Get node_announcements. |
| 1340 | msgs = l1.query_gossip('gossip_timestamp_filter', |
| 1341 | genesis_blockhash, |
| 1342 | '0', '0xFFFFFFFF', |
| 1343 | # Filter out gossip_timestamp_filter, |
| 1344 | # channel_announcement and channel_updates. |
| 1345 | # And pings. |
| 1346 | filters=['0109', '0107', '0102', '0100', '0012']) |
| 1347 | |
| 1348 | # May send its own announcement *twice*, since it always spams us. |
| 1349 | msgs = list(set(msgs)) |
| 1350 | assert len(msgs) == 2 |
| 1351 | assert (bytes("SENIORBEAM", encoding="utf8").hex() in msgs[0] |
| 1352 | or bytes("SENIORBEAM", encoding="utf8").hex() in msgs[1]) |
| 1353 | |
| 1354 | # Restart should re-xmit exact same update on reconnect! |
| 1355 | l1.restart() |
| 1356 | |
| 1357 | msgs2 = l1.query_gossip('gossip_timestamp_filter', |
| 1358 | genesis_blockhash, |
| 1359 | '0', '0xFFFFFFFF', |
| 1360 | # Filter out gossip_timestamp_filter, |
| 1361 | # channel_announcement and channel_updates. |
| 1362 | # And pings. |
| 1363 | filters=['0109', '0107', '0102', '0100', '0012']) |
| 1364 | |
| 1365 | # May send its own announcement *twice*, since it always spams us. |
| 1366 | assert set(msgs) == set(msgs2) |
| 1367 | # Won't have queued up another one, either. |
| 1368 | assert not l1.daemon.is_in_log('node_announcement: delaying') |
| 1369 | |
| 1370 | # Try updating the lease rates ad |
| 1371 | ad = l1.rpc.call('setleaserates', |
nothing calls this directly
no test coverage detected