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

Function test_dump_own_gossip

tests/test_gossip.py:2127–2163  ·  view source on GitHub ↗

We *should* send all self-related gossip unsolicited, if we have any

(node_factory)

Source from the content-addressed store, hash-verified

2125
2126
2127def test_dump_own_gossip(node_factory):
2128 """We *should* send all self-related gossip unsolicited, if we have any"""
2129 l1, l2 = node_factory.line_graph(2, wait_for_announce=True)
2130
2131 # Make sure l1 has updates in both directions, and node_announcements
2132 wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 2)
2133 wait_for(lambda: len(l1.rpc.listnodes()['nodes']) == 2)
2134
2135 # We should get channel_announcement, channel_update, node_announcement.
2136 # (Plus random pings, timestamp_filter)
2137 out = subprocess.run(['devtools/gossipwith',
2138 '--no-gossip',
2139 '--timeout-after={}'.format(int(math.sqrt(TIMEOUT) + 1)),
2140 '--network={}'.format(TEST_NETWORK),
2141 '{}@localhost:{}'.format(l1.info['id'], l1.port)],
2142 check=True,
2143 timeout=TIMEOUT, stdout=subprocess.PIPE).stdout
2144
2145 # In theory, we could do the node_announcement any time after channel_announcement, but we don't.
2146 expect = [256, # channel_announcement
2147 258, # channel_update
2148 258, # channel_update
2149 257] # node_announcement
2150
2151 while len(out):
2152 l, t = struct.unpack('>HH', out[0:4])
2153 out = out[2 + l:]
2154
2155 # Ignore pings, timestamp_filter, query_channel_range
2156 if t in (18, 263, 265):
2157 continue
2158
2159 assert t == expect[0]
2160 expect = expect[1:]
2161
2162 # We should get exactly what we expected.
2163 assert expect == []
2164
2165
2166def test_gossip_throttle(node_factory, bitcoind, chainparams):

Callers

nothing calls this directly

Calls 5

wait_forFunction · 0.90
line_graphMethod · 0.80
listchannelsMethod · 0.45
listnodesMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected