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

Function test_splice_out

tests/test_splicing.py:482–514  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

480@pytest.mark.openchannel('v2')
481@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
482def test_splice_out(node_factory, bitcoind):
483 l1, l2 = node_factory.line_graph(2, fundamount=1000000, wait_for_announce=True)
484
485 chan_id = l1.get_channel_id(l2)
486
487 funds_result = l1.rpc.addpsbtoutput(100000)
488
489 # Pay with fee by subjtracting 5801 from channel balance
490 result = l1.rpc.splice_init(chan_id, -105801, funds_result['psbt'])
491 result = l1.rpc.splice_update(chan_id, result['psbt'])
492 assert(result['commitments_secured'] is False)
493 result = l1.rpc.splice_update(chan_id, result['psbt'])
494 assert(result['commitments_secured'] is True)
495 result = l1.rpc.splice_signed(chan_id, result['psbt'])
496
497 l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
498 l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
499
500 wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
501 mempool = bitcoind.rpc.getrawmempool(True)
502 assert result['txid'] in list(mempool.keys())
503
504 bitcoind.generate_block(6, wait_for_mempool=1)
505
506 l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
507 l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
508
509 inv = l2.rpc.invoice(10**2, '3', 'no_3')
510 l1.rpc.xpay(inv['bolt11'])
511
512 # Check that the splice doesn't generate a unilateral close transaction
513 time.sleep(5)
514 assert l1.db_query("SELECT count(*) as c FROM channeltxs;")[0]['c'] == 0
515
516
517@pytest.mark.openchannel('v1')

Callers

nothing calls this directly

Calls 12

wait_forFunction · 0.90
line_graphMethod · 0.80
get_channel_idMethod · 0.80
addpsbtoutputMethod · 0.80
wait_for_logMethod · 0.80
generate_blockMethod · 0.80
db_queryMethod · 0.80
splice_initMethod · 0.45
splice_updateMethod · 0.45
splice_signedMethod · 0.45
invoiceMethod · 0.45
xpayMethod · 0.45

Tested by

no test coverage detected