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

Function test_script_two_chan_splice_out

tests/test_splice.py:446–478  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

444@pytest.mark.openchannel('v2')
445@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
446def test_script_two_chan_splice_out(node_factory, bitcoind):
447 l1, l2, l3 = node_factory.line_graph(3, fundamount=1000000, wait_for_announce=True)
448
449 # We need to get funds into l1 -> l2 channel so we can splice it out
450 inv = l2.rpc.invoice(100000000, '1', 'no_1')
451 l1.rpc.pay(inv['bolt11'])
452
453 chan_id1 = l2.get_channel_id(l1)
454 chan_id2 = l2.get_channel_id(l3)
455
456 # l2 will splice funds out of the channels with l1 and l3 at the same time
457 # By default extra funds get sent to wallet
458 result = l2.rpc.splice(f"{chan_id1} -> 100000; {chan_id2} -> 100000")
459
460 l3.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
461 l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
462 l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
463
464 wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
465 assert result['txid'] in list(bitcoind.rpc.getrawmempool(True).keys())
466
467 bitcoind.generate_block(6, wait_for_mempool=1)
468
469 l3.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
470 l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
471 l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
472
473 # no extra funds in channels but do some simple payments to test stability
474 inv = l2.rpc.invoice(10000, '2', 'no_2')
475 l1.rpc.pay(inv['bolt11'])
476
477 inv = l3.rpc.invoice(10000, '3', 'no_3')
478 l2.rpc.pay(inv['bolt11'])
479
480
481@pytest.mark.openchannel('v1')

Callers

nothing calls this directly

Calls 8

wait_forFunction · 0.90
line_graphMethod · 0.80
get_channel_idMethod · 0.80
spliceMethod · 0.80
wait_for_logMethod · 0.80
generate_blockMethod · 0.80
invoiceMethod · 0.45
payMethod · 0.45

Tested by

no test coverage detected