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

Function test_v2_open_feerate_out_of_range

tests/test_opening.py:144–173  ·  view source on GitHub ↗

We refuse an open_channel2 whose feerates are outside our bounds. dualopend was never given min_feerate/max_feerate at all, and the openchannel2 hook only *reports* our limits, so with no plugin hooked nothing enforced them: the opener could name any feerate in either direction and

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

142@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
143@pytest.mark.openchannel('v2')
144def test_v2_open_feerate_out_of_range(node_factory, bitcoind):
145 """We refuse an open_channel2 whose feerates are outside our bounds.
146
147 dualopend was never given min_feerate/max_feerate at all, and the
148 openchannel2 hook only *reports* our limits, so with no plugin hooked
149 nothing enforced them: the opener could name any feerate in either
150 direction and we would sign for it and store it.
151 """
152 # l1 has expensive estimates, l2 has cheap ones, so what l1 proposes is
153 # well above what l2 will put up with.
154 l1 = node_factory.get_node(feerates=(50000, 50000, 50000, 50000))
155 l2 = node_factory.get_node(feerates=(3000, 3000, 3000, 3000),
156 allow_warning=True)
157
158 assert l2.rpc.feerates('perkw')['perkw']['max_acceptable'] == 30000
159
160 l1.fundwallet(10**7)
161 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
162
163 # The abort has to name the channel we're opening, or the opener can't
164 # match it up and answers "Unknown channel" instead of failing the open.
165 with pytest.raises(RpcError, match=r'funding_feerate_perkw 50000 above maximum 30000'):
166 l1.rpc.fundchannel(l2.info['id'], 500000)
167
168 l2.daemon.wait_for_log(r'funding_feerate_perkw 50000 above maximum 30000')
169 assert not l1.daemon.is_in_log(r'Unknown channel for WIRE_TX_ABORT')
170
171 # No channel, and nothing stored to trip over later.
172 assert l2.rpc.listpeerchannels()['channels'] == []
173 assert l2.db_query("SELECT count(*) AS c FROM channel_funding_inflights;")[0]['c'] == 0
174
175
176@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')

Callers

nothing calls this directly

Calls 9

fundwalletMethod · 0.80
wait_for_logMethod · 0.80
is_in_logMethod · 0.80
listpeerchannelsMethod · 0.80
db_queryMethod · 0.80
get_nodeMethod · 0.45
feeratesMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected