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

Function test_splice_stuck_htlc

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

Source from the content-addressed store, hash-verified

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