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

Function test_script_two_chan_splice_in

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

Source from the content-addressed store, hash-verified

409@pytest.mark.openchannel('v2')
410@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
411def test_script_two_chan_splice_in(node_factory, bitcoind):
412 l1, l2, l3 = node_factory.line_graph(3, fundamount=1000000, wait_for_announce=True)
413
414 chan_id1 = l2.get_channel_id(l1)
415 chan_id2 = l2.get_channel_id(l3)
416
417 # l2 will splice funds into the channels with l1 and l3 at the same time
418 result = l2.rpc.splice(f"wallet -> 200000+fee; 100000 -> {chan_id1}; 100000 -> {chan_id2}")
419
420 l3.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
421 l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
422 l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
423
424 wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
425 assert result['txid'] in list(bitcoind.rpc.getrawmempool(True).keys())
426
427 bitcoind.generate_block(6, wait_for_mempool=1)
428
429 l3.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
430 l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
431 l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
432
433 # l2 should now have funds on their side to pay l1
434 inv = l1.rpc.invoice(10000, '1', 'no_1')
435 l2.rpc.pay(inv['bolt11'])
436
437 # l2 spliced extra funds into chan with l3 (but l3 still has 0 on their side)
438 # Send a payment l2->l3 just to check for channel stability
439 inv = l3.rpc.invoice(10000, '2', 'no_2')
440 l2.rpc.pay(inv['bolt11'])
441
442
443@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