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

Function test_gossip_pruning

tests/test_gossip.py:29–80  ·  view source on GitHub ↗

Create channel and see it being updated in time before pruning

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

27
28
29def test_gossip_pruning(node_factory, bitcoind):
30 """ Create channel and see it being updated in time before pruning
31 """
32 l1, l2, l3 = node_factory.get_nodes(3, opts={'dev-fast-gossip-prune': None,
33 'allow_bad_gossip': True,
34 'autoconnect-seeker-peers': 0})
35
36 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
37 l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
38
39 scid1, _ = l1.fundchannel(l2, 10**6)
40 scid2, _ = l2.fundchannel(l3, 10**6)
41
42 mine_funding_to_announce(bitcoind, [l1, l2, l3])
43 wait_for(lambda: l1.rpc.listchannels(source=l1.info['id'])['channels'] != [])
44 l1_initial_cupdate_timestamp = only_one(l1.rpc.listchannels(source=l1.info['id'])['channels'])['last_update']
45
46 # Get timestamps of initial updates, so we can ensure they change.
47 # Channels should be activated locally
48 wait_for(lambda: [c['active'] for c in l1.rpc.listchannels()['channels']] == [True] * 4)
49 wait_for(lambda: [c['active'] for c in l2.rpc.listchannels()['channels']] == [True] * 4)
50 wait_for(lambda: [c['active'] for c in l3.rpc.listchannels()['channels']] == [True] * 4)
51
52 # All of them should send a keepalive message (after 120-30 seconds)
53 l1.daemon.wait_for_logs([
54 'Sending keepalive channel_update for {}'.format(scid1),
55 ], timeout=100)
56 l2.daemon.wait_for_logs([
57 'Sending keepalive channel_update for {}'.format(scid1),
58 'Sending keepalive channel_update for {}'.format(scid2),
59 ])
60 l3.daemon.wait_for_logs([
61 'Sending keepalive channel_update for {}'.format(scid2),
62 ])
63
64 # Everyone should see l1's update change.
65 for n in (l1, l2, l3):
66 wait_for(lambda: only_one(n.rpc.listchannels(source=l1.info['id'])['channels'])['last_update'] != l1_initial_cupdate_timestamp)
67
68 # Now kill l2, so that l1 and l3 will prune from their view after 60 seconds
69 l2.stop()
70
71 # We check every 120/4 seconds, and takes 120 seconds since last update.
72 l1.daemon.wait_for_log("Pruning channel {} from network view".format(scid2),
73 timeout=150)
74 l3.daemon.wait_for_log("Pruning channel {} from network view".format(scid1),
75 timeout=150)
76
77 assert scid2 not in [c['short_channel_id'] for c in l1.rpc.listchannels()['channels']]
78 assert scid1 not in [c['short_channel_id'] for c in l3.rpc.listchannels()['channels']]
79 assert l3.info['id'] not in [n['nodeid'] for n in l1.rpc.listnodes()['nodes']]
80 assert l1.info['id'] not in [n['nodeid'] for n in l3.rpc.listnodes()['nodes']]
81
82
83def test_gossip_disable_channels(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 11

mine_funding_to_announceFunction · 0.90
wait_forFunction · 0.90
only_oneFunction · 0.90
get_nodesMethod · 0.80
wait_for_logsMethod · 0.80
wait_for_logMethod · 0.80
connectMethod · 0.45
fundchannelMethod · 0.45
listchannelsMethod · 0.45
stopMethod · 0.45
listnodesMethod · 0.45

Tested by

no test coverage detected