Onchain handling of outgoing failed htlcs
(node_factory, bitcoind, executor, chainparams, anchors)
| 2029 | |
| 2030 | @pytest.mark.parametrize("anchors", [False, True]) |
| 2031 | def test_onchain_timeout(node_factory, bitcoind, executor, chainparams, anchors): |
| 2032 | """Onchain handling of outgoing failed htlcs""" |
| 2033 | |
| 2034 | if chainparams['elements'] and anchors: |
| 2035 | pytest.skip('elementsd anchors unsupported') |
| 2036 | |
| 2037 | # We track channel balances, to verify that accounting is ok. |
| 2038 | coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') |
| 2039 | |
| 2040 | opts = {'plugin': coin_mvt_plugin} |
| 2041 | if anchors is False: |
| 2042 | opts['dev-force-features'] = "-23" |
| 2043 | |
| 2044 | # HTLC 1->2, 1 fails just after it's irrevocably committed |
| 2045 | disconnects = ['+WIRE_REVOKE_AND_ACK*3', 'permfail'] |
| 2046 | # Feerates identical so we don't get gratuitous commit to update them |
| 2047 | l1, l2 = node_factory.line_graph(2, |
| 2048 | opts=[{**opts, **{'disconnect': disconnects, |
| 2049 | 'feerates': (7500, 7500, 7500, 7500)}}, |
| 2050 | opts]) |
| 2051 | |
| 2052 | channel_id = first_channel_id(l1, l2) |
| 2053 | |
| 2054 | inv = l2.rpc.invoice(10**8, 'onchain_timeout', 'desc') |
| 2055 | rhash = inv['payment_hash'] |
| 2056 | # We underpay, so it fails. |
| 2057 | routestep = { |
| 2058 | 'amount_msat': 10**8 - 1, |
| 2059 | 'id': l2.info['id'], |
| 2060 | 'delay': 5, |
| 2061 | 'channel': first_scid(l1, l2) |
| 2062 | } |
| 2063 | |
| 2064 | l1.rpc.sendpay([routestep], rhash, payment_secret=inv['payment_secret'], groupid=1) |
| 2065 | with pytest.raises(RpcError): |
| 2066 | l1.rpc.waitsendpay(rhash) |
| 2067 | |
| 2068 | # Make sure CLTVs are different, in case it confuses onchaind. |
| 2069 | bitcoind.generate_block(1) |
| 2070 | sync_blockheight(bitcoind, [l1]) |
| 2071 | |
| 2072 | # Second one will cause drop to chain. |
| 2073 | l1.rpc.sendpay([routestep], rhash, payment_secret=inv['payment_secret'], groupid=2) |
| 2074 | payfuture = executor.submit(l1.rpc.waitsendpay, rhash) |
| 2075 | |
| 2076 | # l1 will drop to chain. |
| 2077 | l1.daemon.wait_for_log('permfail') |
| 2078 | l1.wait_for_channel_onchain(l2.info['id']) |
| 2079 | l1.bitcoin.generate_block(1) |
| 2080 | l1.daemon.wait_for_log(' to ONCHAIN') |
| 2081 | l2.daemon.wait_for_log(' to ONCHAIN') |
| 2082 | |
| 2083 | # Could happen any order. |
| 2084 | ((_, txid1, blocks1), (_, txid2, blocks2)) = \ |
| 2085 | l1.wait_for_onchaind_txs(('OUR_DELAYED_RETURN_TO_WALLET', |
| 2086 | 'OUR_UNILATERAL/DELAYED_OUTPUT_TO_US'), |
| 2087 | ('OUR_HTLC_TIMEOUT_TX', |
| 2088 | 'OUR_UNILATERAL/OUR_HTLC')) |
nothing calls this directly
no test coverage detected