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

Function test_zeroconf_public

tests/test_opening.py:1353–1453  ·  view source on GitHub ↗

Test that we transition correctly from zeroconf to public The differences being that a public channel MUST use the public scid. l1 and l2 open a zeroconf channel, then l3 learns about it after 6 confirmations.

(bitcoind, node_factory, chainparams)

Source from the content-addressed store, hash-verified

1351
1352
1353def test_zeroconf_public(bitcoind, node_factory, chainparams):
1354 """Test that we transition correctly from zeroconf to public
1355
1356 The differences being that a public channel MUST use the public
1357 scid. l1 and l2 open a zeroconf channel, then l3 learns about it
1358 after 6 confirmations.
1359
1360 """
1361 plugin_path = Path(__file__).parent / "plugins" / "zeroconf-selective.py"
1362 coin_mvt_plugin = Path(__file__).parent / "plugins" / "coin_movements.py"
1363
1364 l1, l2, l3 = node_factory.get_nodes(3, opts=[
1365 {'plugin': str(coin_mvt_plugin)},
1366 {
1367 'plugin': str(plugin_path),
1368 'zeroconf-allow': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518'
1369 },
1370 {}
1371 ])
1372 # Advances blockheight to 102
1373 l1.fundwallet(10**6)
1374 push_msat = 20000 * 1000
1375 l1.connect(l2)
1376 l1.rpc.fundchannel(l2.info['id'], 'all', mindepth=0, push_msat=push_msat)
1377
1378 # Wait for the update to be signed (might not be the most reliable
1379 # signal)
1380 l1.daemon.wait_for_log(r'Got WIRE_HSMD_CUPDATE_SIG_REQ')
1381 l2.daemon.wait_for_log(r'Got WIRE_HSMD_CUPDATE_SIG_REQ')
1382
1383 l1chan = l1.rpc.listpeers()['peers'][0]['channels'][0]
1384 l2chan = l2.rpc.listpeers()['peers'][0]['channels'][0]
1385 channel_id = l1chan['channel_id']
1386
1387 # We have no confirmation yet, so no `short_channel_id`
1388 assert('short_channel_id' not in l1chan)
1389 assert('short_channel_id' not in l2chan)
1390
1391 # Channel is "proposed"
1392 chan_val = 993198000 if chainparams['elements'] else 995673000
1393 l1_mvts = [
1394 {'type': 'chain_mvt', 'credit_msat': chan_val, 'debit_msat': 0, 'tags': ['channel_proposed', 'opener']},
1395 {'type': 'channel_mvt', 'credit_msat': 0, 'debit_msat': 20000000, 'tags': ['pushed'], 'fees_msat': '0msat'},
1396 ]
1397 check_coin_moves(l1, l1chan['channel_id'], l1_mvts, chainparams)
1398
1399 # Check that the channel_open event has blockheight of zero
1400 for n in [l1, l2]:
1401 evs = n.rpc.bkpr_listaccountevents(channel_id)['events']
1402 open_ev = only_one([e for e in evs if e['tag'] == 'channel_proposed'])
1403 assert open_ev['blockheight'] == 0
1404
1405 # Call inspect, should have pending event in it
1406 tx = only_one(n.rpc.bkpr_inspect(channel_id)['txs'])
1407 assert 'blockheight' not in tx
1408 assert only_one(tx['outputs'])['output_tag'] == 'channel_proposed'
1409
1410 # Now add 1 confirmation, we should get a `short_channel_id` (block 103)

Callers

nothing calls this directly

Calls 12

check_coin_movesFunction · 0.90
only_oneFunction · 0.90
wait_forFunction · 0.90
get_nodesMethod · 0.80
fundwalletMethod · 0.80
wait_for_logMethod · 0.80
generate_blockMethod · 0.80
connectMethod · 0.45
fundchannelMethod · 0.45
listpeersMethod · 0.45
listchannelsMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected