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

Function test_channel_features

tests/test_connection.py:3680–3720  ·  view source on GitHub ↗
(node_factory, bitcoind, anchors)

Source from the content-addressed store, hash-verified

3678@pytest.mark.openchannel('v2')
3679@pytest.mark.parametrize("anchors", [False, True])
3680def test_channel_features(node_factory, bitcoind, anchors):
3681 if TEST_NETWORK == 'regtest':
3682 if anchors is False:
3683 opts = {'dev-force-features': "-23"}
3684 else:
3685 opts = {}
3686 else:
3687 # We have to force this ON for elements!
3688 if anchors is False:
3689 opts = {}
3690 else:
3691 opts = {'dev-force-features': "+23"}
3692 l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
3693
3694 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr('bech32')['bech32'], 0.1)
3695 bitcoind.generate_block(1)
3696 wait_for(lambda: l1.rpc.listfunds()['outputs'] != [])
3697
3698 l1.rpc.fundchannel(l2.info['id'], 'all')
3699
3700 # We should see features in unconfirmed channels.
3701 chan = only_one(l1.rpc.listpeerchannels()['channels'])
3702 assert 'option_static_remotekey' in chan['features']
3703 if anchors:
3704 assert 'option_anchors' in chan['features']
3705
3706 # l2 should agree.
3707 assert only_one(l2.rpc.listpeerchannels()['channels'])['features'] == chan['features']
3708
3709 # Confirm it.
3710 bitcoind.generate_block(1)
3711 wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
3712 wait_for(lambda: only_one(l2.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
3713
3714 chan = only_one(l1.rpc.listpeerchannels()['channels'])
3715 assert 'option_static_remotekey' in chan['features']
3716 if anchors:
3717 assert 'option_anchors' in chan['features']
3718
3719 # l2 should agree.
3720 assert only_one(l2.rpc.listpeerchannels()['channels'])['features'] == chan['features']
3721
3722
3723def test_nonstatic_channel(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 8

wait_forFunction · 0.90
only_oneFunction · 0.90
line_graphMethod · 0.80
generate_blockMethod · 0.80
listpeerchannelsMethod · 0.80
newaddrMethod · 0.45
listfundsMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected