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

Function test_zeroconf_open

tests/test_opening.py:2238–2310  ·  view source on GitHub ↗

Let's open a zeroconf channel Just test that both parties opting in results in a channel that is immediately usable.

(bitcoind, node_factory)

Source from the content-addressed store, hash-verified

2236
2237
2238def test_zeroconf_open(bitcoind, node_factory):
2239 """Let's open a zeroconf channel
2240
2241 Just test that both parties opting in results in a channel that is
2242 immediately usable.
2243
2244 """
2245 plugin_path = Path(__file__).parent / "plugins" / "zeroconf-selective.py"
2246
2247 # Without l1->l2, l3 doesn't add a routehint since l2 looks like a deadend
2248 l1, l2, l3 = node_factory.get_nodes(3, opts=[
2249 {},
2250 {},
2251 {
2252 'plugin': str(plugin_path),
2253 'zeroconf_allow': '033845802d25b4e074ccfd7cd8b339a41dc75bf9978a034800444b51d42b07799a'
2254 },
2255 ])
2256
2257 node_factory.join_nodes([l1, l2], wait_for_announce=True)
2258
2259 # Try to open a mindepth=0 channel
2260 l2.fundwallet(10**6)
2261
2262 l2.connect(l3)
2263 assert (int(l2.rpc.listpeers()['peers'][0]['features'], 16) >> 50) & 0x02 != 0
2264
2265 # Now start the negotiation, l2 should have negotiated zeroconf,
2266 # and use their own mindepth=6, while l3 uses mindepth=2 from the
2267 # plugin
2268 ret = l2.rpc.fundchannel(l3.info['id'], 'all', mindepth=0)
2269 if TEST_NETWORK == 'regtest':
2270 channel_type = {'bits': [12, 22, 50], 'names': ['static_remotekey/even', 'anchors/even', 'zeroconf/even']}
2271 else:
2272 channel_type = {'bits': [12, 50], 'names': ['static_remotekey/even', 'zeroconf/even']}
2273 assert ret['channel_type'] == channel_type
2274 assert only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['channel_type'] == channel_type
2275
2276 assert l2.db.query('SELECT minimum_depth FROM channels WHERE minimum_depth != 1') == [{'minimum_depth': 0}]
2277 assert l3.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 0}]
2278
2279 l2.daemon.wait_for_logs([
2280 r'peer_in WIRE_CHANNEL_READY',
2281 r'Peer told us that they\'ll use alias=[0-9x]+ for this channel',
2282 ])
2283 l3.daemon.wait_for_logs([
2284 r'peer_in WIRE_CHANNEL_READY',
2285 r'Peer told us that they\'ll use alias=[0-9x]+ for this channel',
2286 ])
2287
2288 wait_for(lambda: [c['state'] for c in l2.rpc.listpeerchannels()['channels']] == ['CHANNELD_NORMAL'] * 2)
2289 wait_for(lambda: only_one(l3.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
2290 wait_for(lambda: l3.rpc.listincoming()['incoming'] != [])
2291
2292 # Make sure l3 sees l1->l2
2293 wait_for(lambda: l3.rpc.listchannels() != {'channels': []})
2294
2295 inv = l3.rpc.invoice(10**8, 'lbl', 'desc')['bolt11']

Callers

nothing calls this directly

Calls 15

only_oneFunction · 0.90
wait_forFunction · 0.90
get_nodesMethod · 0.80
join_nodesMethod · 0.80
fundwalletMethod · 0.80
listpeerchannelsMethod · 0.80
wait_for_logsMethod · 0.80
wait_for_logMethod · 0.80
connectMethod · 0.45
listpeersMethod · 0.45
fundchannelMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected