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

Function test_splice_stuck_htlc

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

Source from the content-addressed store, hash-verified

454@pytest.mark.openchannel('v2')
455@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
456def test_splice_stuck_htlc(node_factory, bitcoind, executor):
457 l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True)
458
459 l3.rpc.dev_ignore_htlcs(id=l2.info['id'], ignore=True)
460
461 inv = l3.rpc.invoice(10000000, '1', 'no_1')
462 executor.submit(l1.rpc.xpay, inv['bolt11'])
463 l3.daemon.wait_for_log('their htlc 0 dev_ignore_htlcs')
464
465 # Now we should have a stuck invoice between l1 -> l2
466
467 chan_id = l1.get_channel_id(l2)
468
469 # add extra sats to pay fee
470 funds_result = l1.rpc.fundpsbt("111722sat", 0, 0, excess_as_change=True)
471
472 result = l1.rpc.splice_init(chan_id, 100000, funds_result['psbt'])
473 result = l1.rpc.splice_update(chan_id, result['psbt'])
474 assert(result['commitments_secured'] is False)
475 result = l1.rpc.splice_update(chan_id, result['psbt'])
476 assert(result['commitments_secured'] is True)
477 result = l1.rpc.signpsbt(result['psbt'])
478 result = l1.rpc.splice_signed(chan_id, result['signed_psbt'])
479
480 l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
481 l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
482
483 wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
484 mempool = bitcoind.rpc.getrawmempool(True)
485 assert result['txid'] in list(mempool.keys())
486
487 bitcoind.generate_block(1, wait_for_mempool=1)
488 # Don't have l2, l3 reject channel_announcement as too far in future.
489 sync_blockheight(bitcoind, [l1, l2, l3])
490 bitcoind.generate_block(5)
491
492 l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
493 l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
494
495 # Check that the splice doesn't generate a unilateral close transaction
496 time.sleep(5)
497 assert l1.db_query("SELECT count(*) as c FROM channeltxs;")[0]['c'] == 0
498
499
500@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