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

Function test_onchain_all_dust

tests/test_closing.py:2567–2652  ·  view source on GitHub ↗

Onchain handling when we reduce output to all dust

(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

2565
2566@pytest.mark.developer("needs DEVELOPER=1 for dev-set-fees")
2567def test_onchain_all_dust(node_factory, bitcoind, executor):
2568 """Onchain handling when we reduce output to all dust"""
2569 # We track channel balances, to verify that accounting is ok.
2570 coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
2571
2572 # HTLC 1->2, 2 fails just after they're both irrevocably committed
2573 # We need 2 to drop to chain, because then 1's HTLC timeout tx
2574 # is generated on-the-fly, and is thus feerate sensitive.
2575 disconnects = ['-WIRE_UPDATE_FAIL_HTLC', 'permfail']
2576 # Feerates identical so we don't get gratuitous commit to update them
2577 l1 = node_factory.get_node(options={'dev-no-reconnect': None,
2578 'plugin': coin_mvt_plugin},
2579 feerates=(7500, 7500, 7500, 7500))
2580 l2 = node_factory.get_node(disconnect=disconnects, options={'plugin': coin_mvt_plugin})
2581
2582 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
2583 l1.fundchannel(l2, 10**6)
2584 channel_id = first_channel_id(l1, l2)
2585
2586 inv = l2.rpc.invoice(10**8, 'onchain_timeout', 'desc')
2587 rhash = inv['payment_hash']
2588 # We underpay, so it fails.
2589 routestep = {
2590 'amount_msat': 10**7 - 1,
2591 'id': l2.info['id'],
2592 'delay': 5,
2593 'channel': first_scid(l1, l2)
2594 }
2595
2596 executor.submit(l1.rpc.sendpay, [routestep], rhash, payment_secret=inv['payment_secret'])
2597
2598 # l2 will drop to chain.
2599 l2.daemon.wait_for_log('permfail')
2600 l2.wait_for_channel_onchain(l1.info['id'])
2601
2602 # Make l1's fees really high (and wait for it to exceed 50000)
2603 l1.set_feerates((1000000, 1000000, 1000000, 1000000))
2604 l1.daemon.wait_for_log('Feerate estimate for unilateral_close set to [56789][0-9]{4}')
2605
2606 bitcoind.generate_block(1)
2607 l1.daemon.wait_for_log(' to ONCHAIN')
2608 l2.daemon.wait_for_log(' to ONCHAIN')
2609
2610 # Wait for timeout.
2611 l1.daemon.wait_for_log('Propose handling THEIR_UNILATERAL/OUR_HTLC by IGNORING_TINY_PAYMENT .* after 6 blocks')
2612 bitcoind.generate_block(5)
2613
2614 l1.wait_for_onchaind_broadcast('IGNORING_TINY_PAYMENT',
2615 'THEIR_UNILATERAL/OUR_HTLC')
2616 l1.daemon.wait_for_log('Ignoring output .*: THEIR_UNILATERAL/OUR_HTLC')
2617
2618 # 100 deep and l2 forgets.
2619 bitcoind.generate_block(93)
2620 sync_blockheight(bitcoind, [l1, l2])
2621 assert not l2.daemon.is_in_log('onchaind complete, forgetting peer')
2622 assert not l1.daemon.is_in_log('onchaind complete, forgetting peer')
2623 bitcoind.generate_block(1)
2624 l2.daemon.wait_for_log('onchaind complete, forgetting peer')

Callers

nothing calls this directly

Calls 15

first_channel_idFunction · 0.90
first_scidFunction · 0.90
sync_blockheightFunction · 0.90
account_balanceFunction · 0.90
anchor_expectedFunction · 0.90
check_utxos_channelFunction · 0.90
joinMethod · 0.80
wait_for_logMethod · 0.80
set_feeratesMethod · 0.80
generate_blockMethod · 0.80

Tested by

no test coverage detected