Onchain handling when we reduce output to all dust
(node_factory, bitcoind, executor)
| 2975 | |
| 2976 | |
| 2977 | def test_onchain_all_dust(node_factory, bitcoind, executor): |
| 2978 | """Onchain handling when we reduce output to all dust""" |
| 2979 | # We track channel balances, to verify that accounting is ok. |
| 2980 | coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') |
| 2981 | |
| 2982 | # HTLC 1->2, 2 fails just after they're both irrevocably committed |
| 2983 | # We need 2 to drop to chain, because then 1's HTLC timeout tx |
| 2984 | # is generated on-the-fly, and is thus feerate sensitive. |
| 2985 | disconnects = ['-WIRE_UPDATE_FAIL_HTLC', 'permfail'] |
| 2986 | # Feerates identical so we don't get gratuitous commit to update them |
| 2987 | l1 = node_factory.get_node(options={'dev-no-reconnect': None, |
| 2988 | 'plugin': coin_mvt_plugin}, |
| 2989 | feerates=(7500, 7500, 7500, 7500)) |
| 2990 | l2 = node_factory.get_node(disconnect=disconnects, options={'plugin': coin_mvt_plugin}) |
| 2991 | |
| 2992 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 2993 | l1.fundchannel(l2, 10**6) |
| 2994 | channel_id = first_channel_id(l1, l2) |
| 2995 | |
| 2996 | inv = l2.rpc.invoice(10**8, 'onchain_timeout', 'desc') |
| 2997 | rhash = inv['payment_hash'] |
| 2998 | # We underpay, so it fails. |
| 2999 | routestep = { |
| 3000 | 'amount_msat': 10**7 - 1, |
| 3001 | 'id': l2.info['id'], |
| 3002 | 'delay': 5, |
| 3003 | 'channel': first_scid(l1, l2) |
| 3004 | } |
| 3005 | |
| 3006 | executor.submit(l1.rpc.sendpay, [routestep], rhash, payment_secret=inv['payment_secret']) |
| 3007 | |
| 3008 | # l2 will drop to chain. |
| 3009 | l2.daemon.wait_for_log('permfail') |
| 3010 | l2.wait_for_channel_onchain(l1.info['id']) |
| 3011 | |
| 3012 | # Make l1's fees really high (and wait for it to exceed 50000) |
| 3013 | l1.set_feerates((1000000, 1000000, 1000000, 1000000)) |
| 3014 | wait_for(lambda: all(e['smoothed_feerate'] > 50000 for e in l1.rpc.feerates('perkw')['perkw']['estimates'])) |
| 3015 | |
| 3016 | bitcoind.generate_block(1) |
| 3017 | l1.daemon.wait_for_log(' to ONCHAIN') |
| 3018 | l2.daemon.wait_for_log(' to ONCHAIN') |
| 3019 | |
| 3020 | # Wait for timeout. |
| 3021 | _, txid, blocks = l1.wait_for_onchaind_tx('OUR_HTLC_TIMEOUT_TO_US', |
| 3022 | 'THEIR_UNILATERAL/OUR_HTLC') |
| 3023 | assert blocks == 5 |
| 3024 | # FIXME: l1 ignores it, *but it gets mined anyway* |
| 3025 | l1.daemon.wait_for_log("Ignoring output .*: THEIR_UNILATERAL/OUR_HTLC") |
| 3026 | bitcoind.generate_block(5) |
| 3027 | |
| 3028 | # 100 deep and l2 forgets. |
| 3029 | mined = bitcoind.generate_block(93, wait_for_mempool=txid) |
| 3030 | sync_blockheight(bitcoind, [l1, l2]) |
| 3031 | assert not l2.daemon.is_in_log('onchaind complete, forgetting peer') |
| 3032 | assert not l1.daemon.is_in_log('onchaind complete, forgetting peer') |
| 3033 | |
| 3034 | # l1 must rebuild its "we gave up on this, but it got mined anyway" |
nothing calls this directly
no test coverage detected