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

Function test_opening_tiny_channel

tests/test_connection.py:304–368  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

302@pytest.mark.openchannel('v1')
303@pytest.mark.openchannel('v2')
304def test_opening_tiny_channel(node_factory):
305 # Test custom min-capacity-sat parameters
306 #
307 # [l1]-----> [l2] (~6000) - technical minimal value that wont be rejected
308 # \
309 # o---> [l3] (10000) - the current default
310 # \
311 # o-> [l4] (20000) - a node with a higher minimal value
312 #
313 # For each:
314 # 1. Try to establish channel with capacity 1sat smaller than min_capacity_sat
315 # 2. Try to establish channel with capacity exact min_capacity_sat
316 #
317 # BOLT2
318 # The receiving node MAY fail the channel if:
319 # - funding_satoshis is too small
320 # - it considers `feerate_per_kw` too small for timely processing or unreasonably large.
321 #
322 dustlimit = 546
323 reserves = 2 * dustlimit
324 min_commit_tx_fees = basic_fee(7500)
325 overhead = reserves + min_commit_tx_fees
326 if EXPERIMENTAL_FEATURES or EXPERIMENTAL_DUAL_FUND:
327 # Gotta fund those anchors too!
328 overhead += 660
329
330 l2_min_capacity = 1 # just enough to get past capacity filter
331 l3_min_capacity = 10000 # the current default
332 l4_min_capacity = 20000 # a server with more than default minimum
333
334 opts = [{'min-capacity-sat': 0, 'dev-no-reconnect': None},
335 {'min-capacity-sat': l2_min_capacity, 'dev-no-reconnect': None},
336 {'min-capacity-sat': l3_min_capacity, 'dev-no-reconnect': None},
337 {'min-capacity-sat': l4_min_capacity, 'dev-no-reconnect': None}]
338 l1, l2, l3, l4 = node_factory.get_nodes(4, opts=opts)
339 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
340 l1.rpc.connect(l3.info['id'], 'localhost', l3.port)
341 l1.rpc.connect(l4.info['id'], 'localhost', l4.port)
342
343 with pytest.raises(RpcError, match=r'They sent [error|warning].*channel capacity is .*, which is below .*sat'):
344 l1.fundchannel(l2, l2_min_capacity + overhead - 1)
345 wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == [])
346 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
347 l1.fundchannel(l2, l2_min_capacity + overhead)
348
349 with pytest.raises(RpcError, match=r'They sent [error|warning].*channel capacity is .*, which is below .*sat'):
350 l1.fundchannel(l3, l3_min_capacity + overhead - 1)
351 wait_for(lambda: l1.rpc.listpeers(l3.info['id'])['peers'] == [])
352 l1.rpc.connect(l3.info['id'], 'localhost', l3.port)
353 l1.fundchannel(l3, l3_min_capacity + overhead)
354
355 with pytest.raises(RpcError, match=r'They sent [error|warning].*channel capacity is .*, which is below .*sat'):
356 l1.fundchannel(l4, l4_min_capacity + overhead - 1)
357 wait_for(lambda: l1.rpc.listpeers(l4.info['id'])['peers'] == [])
358 l1.rpc.connect(l4.info['id'], 'localhost', l4.port)
359 l1.fundchannel(l4, l4_min_capacity + overhead)
360
361 # Note that this check applies locally too, so you can't open it if

Callers

nothing calls this directly

Calls 6

basic_feeFunction · 0.90
wait_forFunction · 0.90
get_nodesMethod · 0.80
connectMethod · 0.45
fundchannelMethod · 0.45
listpeersMethod · 0.45

Tested by

no test coverage detected