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

Function test_zeroconf_public

tests/test_opening.py:1660–1759  ·  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

1658
1659
1660def test_zeroconf_public(bitcoind, node_factory, chainparams):
1661 """Test that we transition correctly from zeroconf to public
1662
1663 The differences being that a public channel MUST use the public
1664 scid. l1 and l2 open a zeroconf channel, then l3 learns about it
1665 after 6 confirmations.
1666
1667 """
1668 plugin_path = Path(__file__).parent / "plugins" / "zeroconf-selective.py"
1669 coin_mvt_plugin = Path(__file__).parent / "plugins" / "coin_movements.py"
1670
1671 l1, l2, l3 = node_factory.get_nodes(3, opts=[
1672 {'plugin': str(coin_mvt_plugin)},
1673 {
1674 'plugin': str(plugin_path),
1675 'zeroconf_allow': '038194b5f32bdf0aa59812c86c4ef7ad2f294104fa027d1ace9b469bb6f88cf37b'
1676 },
1677 {}
1678 ])
1679 # Advances blockheight to 102
1680 l1.fundwallet(10**6)
1681 push_msat = 20000 * 1000
1682 l1.connect(l2)
1683 l1.rpc.fundchannel(l2.info['id'], 'all', mindepth=0, push_msat=push_msat)
1684
1685 # Wait for the alias to be sent to peer.
1686 wait_for(lambda: 'remote' in only_one(l1.rpc.listpeerchannels()['channels'])['updates'])
1687 wait_for(lambda: 'remote' in only_one(l2.rpc.listpeerchannels()['channels'])['updates'])
1688
1689 l1chan = only_one(l1.rpc.listpeerchannels()['channels'])
1690 l2chan = only_one(l2.rpc.listpeerchannels()['channels'])
1691 channel_id = l1chan['channel_id']
1692
1693 # We have no confirmation yet, so no `short_channel_id`
1694 assert('short_channel_id' not in l1chan)
1695 assert('short_channel_id' not in l2chan)
1696
1697 # Channel is "proposed"
1698 chan_val = 993888000 if chainparams['elements'] else 970073000
1699 l1_mvts = [
1700 {'type': 'chain_mvt', 'credit_msat': chan_val, 'debit_msat': 0, 'tags': ['channel_proposed', 'opener']},
1701 {'type': 'channel_mvt', 'credit_msat': 0, 'debit_msat': 20000000, 'tags': ['pushed'], 'fees_msat': '0msat'},
1702 ]
1703 check_coin_moves(l1, l1chan['channel_id'], l1_mvts, chainparams)
1704
1705 # Check that the channel_open event has blockheight of zero
1706 for n in [l1, l2]:
1707 evs = n.rpc.bkpr_listaccountevents(channel_id)['events']
1708 open_ev = only_one([e for e in evs if e['tag'] == 'channel_proposed'])
1709 assert open_ev['blockheight'] == 0
1710
1711 # Call inspect, should have pending event in it
1712 tx = only_one(n.rpc.bkpr_inspect(channel_id)['txs'])
1713 assert 'blockheight' not in tx
1714 assert only_one(tx['outputs'])['output_tag'] == 'channel_proposed'
1715
1716 # Now add 1 confirmation, we should get a `short_channel_id` (block 103)
1717 bitcoind.generate_block(1)

Callers

nothing calls this directly

Calls 13

wait_forFunction · 0.90
only_oneFunction · 0.90
check_coin_movesFunction · 0.90
get_nodesMethod · 0.80
fundwalletMethod · 0.80
listpeerchannelsMethod · 0.80
bkpr_inspectMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
connectMethod · 0.45
fundchannelMethod · 0.45
listchannelsMethod · 0.45

Tested by

no test coverage detected