https://github.com/ElementsProject/lightning/issues/4649 We send an HTLC, and peer unilaterally closes: do we close upstream?
(node_factory, bitcoind)
| 4096 | |
| 4097 | |
| 4098 | def test_onchain_close_upstream(node_factory, bitcoind): |
| 4099 | """https://github.com/ElementsProject/lightning/issues/4649 |
| 4100 | |
| 4101 | We send an HTLC, and peer unilaterally closes: do we close upstream? |
| 4102 | """ |
| 4103 | l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, |
| 4104 | opts=[{'feerates': (7500, 7500, 7500, 7500)}, |
| 4105 | # Second commitment_signed is to l3 |
| 4106 | {'disconnect': ['xWIRE_COMMITMENT_SIGNED*2'], |
| 4107 | # We want htlc killed by timeout, not a close due to ping timer. |
| 4108 | 'dev-no-ping-timer': None}, |
| 4109 | {'dev-no-ping-timer': None}]) |
| 4110 | |
| 4111 | ph1 = l3.rpc.invoice(amount_msat="10000sat", label='x1', description='desc2')['payment_hash'] |
| 4112 | ph2 = l3.rpc.invoice(amount_msat="10000sat", label='x2', description='desc2')['payment_hash'] |
| 4113 | |
| 4114 | route = l1.single_route(l3.info['id'], 1) |
| 4115 | |
| 4116 | # Start a payment |
| 4117 | l1.rpc.sendpay(route, ph1) |
| 4118 | |
| 4119 | # l3 sends commitment_signed, then silence. |
| 4120 | l2.daemon.wait_for_log('dev_disconnect: xWIRE_COMMITMENT_SIGNED') |
| 4121 | |
| 4122 | # Send another payment, this times out. |
| 4123 | l1.rpc.sendpay(route, ph2) |
| 4124 | |
| 4125 | # This can take 30 seconds... |
| 4126 | l2.daemon.wait_for_log('Adding HTLC 1 too slow: killing connection', |
| 4127 | timeout=TIMEOUT + 30) |
| 4128 | l2.daemon.wait_for_log('Failing HTLC 1 due to peer death') |
| 4129 | |
| 4130 | with pytest.raises(RpcError, match=r'WIRE_TEMPORARY_CHANNEL_FAILURE \(reply from remote\)'): |
| 4131 | l1.rpc.waitsendpay(ph2, timeout=TIMEOUT) |
| 4132 | |
| 4133 | # An important response to the timeout is to force a reconnect, |
| 4134 | # since the problem may be TCP connectivity. |
| 4135 | assert only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['peer_connected'] is False |
| 4136 | |
| 4137 | # Make close unilaterally. |
| 4138 | l3.rpc.close(l2.info['id'], 1) |
| 4139 | |
| 4140 | l3.daemon.wait_for_log('sendrawtransaction') |
| 4141 | |
| 4142 | # Mine it |
| 4143 | bitcoind.generate_block(1, wait_for_mempool=1) |
| 4144 | |
| 4145 | # l2 tells onchaind to look for missing HTLC. |
| 4146 | l2.daemon.wait_for_logs(['Their unilateral tx', |
| 4147 | r'We want to know if htlc 0 is missing \(later\)']) |
| 4148 | |
| 4149 | # # l1 disconnects now |
| 4150 | # l1.rpc.disconnect(l2.info['id'], force=True) |
| 4151 | # # Restart now, and reconnect |
| 4152 | # l2.restart() |
| 4153 | # l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 4154 | |
| 4155 | # After three blocks, onchaind says: definitely missing htlc |
nothing calls this directly
no test coverage detected