We change gossip_store file (additions, deletion) during compaction
(node_factory, bitcoind, executor)
| 1663 | |
| 1664 | |
| 1665 | def test_gossip_store_compact_while_extending(node_factory, bitcoind, executor): |
| 1666 | """We change gossip_store file (additions, deletion) during compaction""" |
| 1667 | l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, |
| 1668 | opts=[{'subdaemon': 'gossip_compactd:../tests/plugins/compacter-slow.sh'}, {}, {}]) |
| 1669 | l2.rpc.setchannel(l3.info['id'], 20, 1000) |
| 1670 | l3.rpc.setchannel(l2.info['id'], 21, 1001) |
| 1671 | |
| 1672 | # Wait for it to hit l2's gossip store. |
| 1673 | wait_for(lambda: sorted([c['fee_per_millionth'] for c in l1.rpc.listchannels()['channels']]) == [10, 10, 1000, 1001]) |
| 1674 | |
| 1675 | # We start compaction, but gossip store continues |
| 1676 | fut = executor.submit(l1.rpc.call, 'dev-compact-gossip-store') |
| 1677 | # Make sure it started! |
| 1678 | l1.daemon.wait_for_log('Executing lightning_gossip_compactd') |
| 1679 | |
| 1680 | # We make another channel, remove old one |
| 1681 | l4 = node_factory.get_node() |
| 1682 | node_factory.join_nodes([l3, l4], wait_for_announce=True) |
| 1683 | scid34 = only_one(l4.rpc.listpeerchannels()['channels'])['short_channel_id'] |
| 1684 | wait_for(lambda: len(l1.rpc.listchannels(scid34)['channels']) == 2) |
| 1685 | |
| 1686 | scid23 = only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['short_channel_id'] |
| 1687 | l2.rpc.close(l3.info['id']) |
| 1688 | bitcoind.generate_block(73, wait_for_mempool=1) |
| 1689 | wait_for(lambda: l1.rpc.listchannels(scid23) == {'channels': []}) |
| 1690 | |
| 1691 | l1.rpc.setchannel(l2.info['id'], 41, 1004) |
| 1692 | scid12 = only_one(l1.rpc.listpeerchannels()['channels'])['short_channel_id'] |
| 1693 | wait_for(lambda: sorted([c['fee_per_millionth'] for c in l1.rpc.listchannels(scid12)['channels']]) == [10, 1004]) |
| 1694 | |
| 1695 | pre_channels = l1.rpc.listchannels() |
| 1696 | # Make sure all node_announcements have been seen. |
| 1697 | wait_for(lambda: all(['alias' in n for n in l1.rpc.listnodes()['nodes']])) |
| 1698 | pre_nodes = sorted(l1.rpc.listnodes()['nodes'], key=lambda n: n['nodeid']) |
| 1699 | |
| 1700 | # Compaction "continues". |
| 1701 | with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'compactd-continue'), 'wb') as f: |
| 1702 | f.write(b'') |
| 1703 | |
| 1704 | fut.result(TIMEOUT) |
| 1705 | # Exact gossip size varies with SPLICING. |
| 1706 | l1.daemon.wait_for_logs(['gossipd: compaction done', |
| 1707 | 'connectd: Reopened gossip_store, reduced to offset 224[59]']) |
| 1708 | |
| 1709 | post_channels = l1.rpc.listchannels() |
| 1710 | post_nodes = sorted(l1.rpc.listnodes()['nodes'], key=lambda n: n['nodeid']) |
| 1711 | l1.daemon.wait_for_log('topology: Reopened gossip_store, reduced to offset 224[59]') |
| 1712 | |
| 1713 | assert post_channels == pre_channels |
| 1714 | assert post_nodes == pre_nodes |
| 1715 | |
| 1716 | |
| 1717 | def test_gossip_store_compact_miss_update(node_factory, bitcoind, executor): |
nothing calls this directly
no test coverage detected