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

Function test_splice_stuck_htlc

tests/test_splicing.py:628–669  ·  view source on GitHub ↗
(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

626@pytest.mark.openchannel('v2')
627@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
628def test_splice_stuck_htlc(node_factory, bitcoind, executor):
629 l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True)
630
631 l3.rpc.dev_ignore_htlcs(id=l2.info['id'], ignore=True)
632
633 inv = l3.rpc.invoice(10000000, '1', 'no_1')
634 executor.submit(l1.rpc.xpay, inv['bolt11'])
635 l3.daemon.wait_for_log('their htlc 0 dev_ignore_htlcs')
636
637 # Now we should have a stuck invoice between l1 -> l2
638
639 chan_id = l1.get_channel_id(l2)
640
641 # add extra sats to pay fee
642 funds_result = l1.rpc.fundpsbt("111722sat", 0, 0, excess_as_change=True)
643
644 result = l1.rpc.splice_init(chan_id, 100000, funds_result['psbt'])
645 result = l1.rpc.splice_update(chan_id, result['psbt'])
646 assert(result['commitments_secured'] is False)
647 result = l1.rpc.splice_update(chan_id, result['psbt'])
648 assert(result['commitments_secured'] is True)
649 result = l1.rpc.signpsbt(result['psbt'])
650 result = l1.rpc.splice_signed(chan_id, result['signed_psbt'])
651
652 l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
653 l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
654
655 wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
656 mempool = bitcoind.rpc.getrawmempool(True)
657 assert result['txid'] in list(mempool.keys())
658
659 bitcoind.generate_block(1, wait_for_mempool=1)
660 # Don't have l2, l3 reject channel_announcement as too far in future.
661 sync_blockheight(bitcoind, [l1, l2, l3])
662 bitcoind.generate_block(5)
663
664 l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
665 l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
666
667 # Check that the splice doesn't generate a unilateral close transaction
668 time.sleep(5)
669 assert l1.db_query("SELECT count(*) as c FROM channeltxs;")[0]['c'] == 0
670
671
672@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')

Callers

nothing calls this directly

Calls 13

wait_forFunction · 0.90
sync_blockheightFunction · 0.90
line_graphMethod · 0.80
wait_for_logMethod · 0.80
get_channel_idMethod · 0.80
fundpsbtMethod · 0.80
signpsbtMethod · 0.80
generate_blockMethod · 0.80
db_queryMethod · 0.80
invoiceMethod · 0.45
splice_initMethod · 0.45
splice_updateMethod · 0.45

Tested by

no test coverage detected