From db003257ff85e8eaa9240eade367fb5bac3aa4eb Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 4 Mar 2026 18:12:53 +0000 Subject: [PATCH] tests: lnpeer: make mpp_cleanup_after_expiry more robust As there are two htlcs, the `alice_htlc_resolved` Event might get set either once or twice by the time `alice_htlc_resolved.wait()` returns. The previous code was assuming that both htlcs are resolved by then, but it could happen that only one htlc was resolved, due to timing. --- tests/test_lnpeer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_lnpeer.py b/tests/test_lnpeer.py index e1a9c0b67..ed7338559 100644 --- a/tests/test_lnpeer.py +++ b/tests/test_lnpeer.py @@ -1532,7 +1532,9 @@ class TestPeerDirect(TestPeer): assert bob_wallet.received_mpp_htlcs[bob_payment_key].resolution == RecvMPPResolution.WAITING assert len(bob_wallet.received_mpp_htlcs[bob_payment_key].htlcs) == 2 # now wait until bob expires the mpp (set) - await asyncio.wait_for(alice_htlc_resolved.wait(), bob_wallet.MPP_EXPIRY * 3) # this can take some time, esp. on CI + async with util.async_timeout(bob_wallet.MPP_EXPIRY * 3): # this can take some time, esp. on CI + while nhtlc_success + nhtlc_failed < 2: + await alice_htlc_resolved.wait() # check that bob failed the htlc assert nhtlc_success == 0 and nhtlc_failed == 2 # check that bob deleted the mpp set as it should be expired and resolved now