Onchain handling when we restart with different fees
(node_factory, bitcoind, executor)
| 2898 | |
| 2899 | |
| 2900 | def test_onchain_feechange(node_factory, bitcoind, executor): |
| 2901 | """Onchain handling when we restart with different fees""" |
| 2902 | # HTLC 1->2, 2 fails just after they're both irrevocably committed |
| 2903 | # We need 2 to drop to chain, because then 1's HTLC timeout tx |
| 2904 | # is generated on-the-fly, and is thus feerate sensitive. |
| 2905 | disconnects = ['-WIRE_UPDATE_FAIL_HTLC', 'permfail'] |
| 2906 | l1, l2 = node_factory.line_graph(2, opts=[ |
| 2907 | { |
| 2908 | 'may_reconnect': True, |
| 2909 | 'allow_warning': True, |
| 2910 | }, { |
| 2911 | 'may_reconnect': True, |
| 2912 | 'disconnect': disconnects, |
| 2913 | } |
| 2914 | ]) |
| 2915 | |
| 2916 | inv = l2.rpc.invoice(10**8, 'onchain_timeout', 'desc') |
| 2917 | rhash = inv['payment_hash'] |
| 2918 | # We underpay, so it fails. |
| 2919 | routestep = { |
| 2920 | 'amount_msat': 10**8 - 1, |
| 2921 | 'id': l2.info['id'], |
| 2922 | 'delay': 5, |
| 2923 | 'channel': first_scid(l1, l2) |
| 2924 | } |
| 2925 | |
| 2926 | executor.submit(l1.rpc.sendpay, [routestep], rhash, payment_secret=inv['payment_secret']) |
| 2927 | |
| 2928 | # l2 will drop to chain. |
| 2929 | l2.daemon.wait_for_log('permfail') |
| 2930 | l2.wait_for_channel_onchain(l1.info['id']) |
| 2931 | bitcoind.generate_block(1) |
| 2932 | l1.daemon.wait_for_log(' to ONCHAIN') |
| 2933 | l2.daemon.wait_for_log(' to ONCHAIN') |
| 2934 | |
| 2935 | _, txid, blocks = l1.wait_for_onchaind_tx('OUR_HTLC_TIMEOUT_TO_US', |
| 2936 | 'THEIR_UNILATERAL/OUR_HTLC') |
| 2937 | assert blocks == 5 |
| 2938 | bitcoind.generate_block(5) |
| 2939 | |
| 2940 | # Could be RBF! |
| 2941 | l1.mine_txid_or_rbf(txid) |
| 2942 | # Now we restart with different feerates. |
| 2943 | l1.stop() |
| 2944 | |
| 2945 | l1.daemon.cmd_line.append('--override-fee-rates=20000/9000/2000') |
| 2946 | l1.start() |
| 2947 | |
| 2948 | # We recognize different proposal as ours. |
| 2949 | l1.daemon.wait_for_log('Resolved THEIR_UNILATERAL/OUR_HTLC by our proposal OUR_HTLC_TIMEOUT_TO_US') |
| 2950 | |
| 2951 | # We use 3 blocks for "reasonable depth", so add two more |
| 2952 | bitcoind.generate_block(2) |
| 2953 | |
| 2954 | # Note that the very similar test_onchain_timeout looks for a |
| 2955 | # different string: that's because it sees the JSONRPC response, |
| 2956 | # and due to the l1 restart, there is none here. |
| 2957 | l1.daemon.wait_for_log('WIRE_PERMANENT_CHANNEL_FAILURE') |
nothing calls this directly
no test coverage detected