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

Function test_funder_options

tests/test_opening.py:2066–2127  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

2064@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
2065@pytest.mark.openchannel('v2')
2066def test_funder_options(node_factory, bitcoind):
2067 l1, l2, l3 = node_factory.get_nodes(3)
2068 l1.fundwallet(10**7)
2069
2070 # Check the default options
2071 funder_opts = l1.rpc.call('funderupdate')
2072
2073 assert funder_opts['policy'] == 'fixed'
2074 assert funder_opts['policy_mod'] == 0
2075 assert funder_opts['min_their_funding_msat'] == Millisatoshi('10000000msat')
2076 assert funder_opts['max_their_funding_msat'] == Millisatoshi('4294967295000msat')
2077 assert funder_opts['per_channel_min_msat'] == Millisatoshi('10000000msat')
2078 assert funder_opts['per_channel_max_msat'] == Millisatoshi('4294967295000msat')
2079 assert funder_opts['reserve_tank_msat'] == Millisatoshi('0msat')
2080 assert funder_opts['fuzz_percent'] == 0
2081 assert funder_opts['fund_probability'] == 100
2082 assert funder_opts['leases_only']
2083
2084 # l2 funds a chanenl with us. We don't contribute
2085 l2.rpc.connect(l1.info['id'], 'localhost', l1.port)
2086 l2.fundchannel(l1, 10**6)
2087 chan_info = only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])
2088 # l1 contributed nothing
2089 assert chan_info['funding']['remote_funds_msat'] == Millisatoshi('0msat')
2090 assert chan_info['funding']['local_funds_msat'] != Millisatoshi('0msat')
2091
2092 # Change all the options
2093 funder_opts = l1.rpc.call('funderupdate',
2094 {'policy': 'available',
2095 'policy_mod': 100,
2096 'min_their_funding_msat': '100000msat',
2097 'max_their_funding_msat': '2000000000msat',
2098 'per_channel_min_msat': '8000000msat',
2099 'per_channel_max_msat': '10000000000msat',
2100 'reserve_tank_msat': '3000000msat',
2101 'fund_probability': 99,
2102 'fuzz_percent': 0,
2103 'leases_only': False})
2104
2105 assert funder_opts['policy'] == 'available'
2106 assert funder_opts['policy_mod'] == 100
2107 assert funder_opts['min_their_funding_msat'] == Millisatoshi('100000msat')
2108 assert funder_opts['max_their_funding_msat'] == Millisatoshi('2000000000msat')
2109 assert funder_opts['per_channel_min_msat'] == Millisatoshi('8000000msat')
2110 assert funder_opts['per_channel_max_msat'] == Millisatoshi('10000000000msat')
2111 assert funder_opts['reserve_tank_msat'] == Millisatoshi('3000000msat')
2112 assert funder_opts['fuzz_percent'] == 0
2113 assert funder_opts['fund_probability'] == 99
2114
2115 # Set the fund probability back up to 100.
2116 funder_opts = l1.rpc.call('funderupdate',
2117 {'fund_probability': 100})
2118 l3.rpc.connect(l1.info['id'], 'localhost', l1.port)
2119 l3.fundchannel(l1, 10**6)
2120 chan_info = only_one(l3.rpc.listpeerchannels(l1.info['id'])['channels'])
2121 log = l1.daemon.wait_for_log(r'Policy available \(100%\) returned funding amount of')
2122 match = re.search(r'Policy available \(100%\) returned funding amount of (\d*sat)', log)
2123 assert match and len(match.groups()) == 1

Callers

nothing calls this directly

Calls 9

MillisatoshiClass · 0.90
only_oneFunction · 0.90
get_nodesMethod · 0.80
fundwalletMethod · 0.80
listpeerchannelsMethod · 0.80
wait_for_logMethod · 0.80
callMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected