Reprotest for #8147: We should not forget a channel on which we received a zeroconf payment. The channel forgetting code actually uses the fact that we ever had a non-zero amount in this channel.
(node_factory, bitcoind, dopay: bool)
| 3343 | |
| 3344 | @pytest.mark.parametrize("dopay", [True, False]) # Whether to send a payment or not |
| 3345 | def test_zeroconf_forget(node_factory, bitcoind, dopay: bool): |
| 3346 | """Reprotest for #8147: We should not forget a channel on which we received a zeroconf payment. |
| 3347 | |
| 3348 | The channel forgetting code actually uses the fact that we ever |
| 3349 | had a non-zero amount in this channel. |
| 3350 | |
| 3351 | """ |
| 3352 | blocks = 50 |
| 3353 | plugin_path = Path(__file__).parent / "plugins" / "zeroconf-selective.py" |
| 3354 | l1, l2, l3 = node_factory.get_nodes( |
| 3355 | 3, |
| 3356 | opts=[ |
| 3357 | {}, |
| 3358 | { |
| 3359 | "plugin": str(plugin_path), |
| 3360 | "zeroconf_allow": "038194b5f32bdf0aa59812c86c4ef7ad2f294104fa027d1ace9b469bb6f88cf37b", |
| 3361 | "zeroconf_mindepth": "0", |
| 3362 | "dev-max-funding-unconfirmed-blocks": blocks, |
| 3363 | }, |
| 3364 | {}, |
| 3365 | ], |
| 3366 | ) |
| 3367 | |
| 3368 | # Make it such that l1 cannot broadcast transactions |
| 3369 | def censoring_sendrawtx(tx): |
| 3370 | return {"id": tx["id"], "result": {}} |
| 3371 | |
| 3372 | l1.daemon.rpcproxy.mock_rpc("sendrawtransaction", censoring_sendrawtx) |
| 3373 | l3.daemon.rpcproxy.mock_rpc("sendrawtransaction", censoring_sendrawtx) |
| 3374 | |
| 3375 | l1.fundwallet(10**7) |
| 3376 | l3.fundwallet(10**7) |
| 3377 | sync_blockheight(bitcoind, [l2]) |
| 3378 | |
| 3379 | l1.connect(l2) |
| 3380 | l1.rpc.fundchannel(l2.info["id"], 10**6, mindepth=0) |
| 3381 | wait_for(lambda: l2.rpc.listincoming()["incoming"] != []) |
| 3382 | |
| 3383 | # If we are told to pay while still not confirmed we perform one |
| 3384 | # payment. This causes us to have a non-zero stake in the channel, |
| 3385 | # thus we should not forget the channel. If we don't then our |
| 3386 | # stake will remain 0msat, hence we can forget the channel without |
| 3387 | # risking any of our funds. |
| 3388 | if dopay: |
| 3389 | inv = l2.rpc.invoice(1, "payme", "my stake in the unconfirmed channel") |
| 3390 | l1.rpc.xpay(inv["bolt11"]) |
| 3391 | wait_for(lambda: only_one(l2.rpc.listpeerchannels()['channels'])['to_us_msat'] == 1) |
| 3392 | |
| 3393 | # We need *another* channel to make it forget the first though! (One block later, otherwise |
| 3394 | # *this* might be forgotten). |
| 3395 | bitcoind.generate_block(1) |
| 3396 | sync_blockheight(bitcoind, [l2]) |
| 3397 | |
| 3398 | l3.connect(l2) |
| 3399 | l3.rpc.fundchannel(l2.info["id"], 10**6, mindepth=0) |
| 3400 | bitcoind.generate_block(1) |
| 3401 | |
| 3402 | # Now stop, in order to cause catchup and re-evaluate whether to forget the channel |
nothing calls this directly
no test coverage detected