Skip to content

Commit c189360

Browse files
authored
Merge pull request #10590 from SomberNight/202604_test_lnpeer_flaky_hold_invoice_set
tests: lnpeer: fix flaky test "hold_invoice_set_doesnt_get_expired"
2 parents 1bea239 + ca8bdba commit c189360

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

tests/test_lnpeer.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,25 +1883,15 @@ async def run_test(test_trampoline):
18831883
del bob_w._preimages[pay_req.rhash] # del preimage so bob doesn't settle
18841884
payment_key = bob_w._get_payment_key(lnaddr.paymenthash).hex()
18851885

1886-
cb_got_called = False
1886+
cb_got_called = asyncio.Event()
18871887
async def cb(_payment_hash):
18881888
self.logger.debug(f"hold invoice callback called. {bob_w.network.get_local_height()=}")
1889-
nonlocal cb_got_called
1890-
cb_got_called = True
1889+
cb_got_called.set()
18911890

18921891
bob_w.register_hold_invoice(lnaddr.paymenthash, cb)
18931892

18941893
async def check_mpp_state():
1895-
async def wait_for_resolution():
1896-
while True:
1897-
await asyncio.sleep(0.1)
1898-
if payment_key not in bob_w.received_mpp_htlcs:
1899-
continue
1900-
if not bob_w.received_mpp_htlcs[payment_key].resolution == RecvMPPResolution.SETTLING:
1901-
continue
1902-
return
1903-
await util.wait_for2(wait_for_resolution(), timeout=2)
1904-
assert cb_got_called
1894+
await util.wait_for2(cb_got_called.wait(), timeout=2)
19051895
mpp_set = bob_w.received_mpp_htlcs[payment_key]
19061896
self.assertEqual(mpp_set.resolution, RecvMPPResolution.SETTLING, msg=mpp_set.resolution)
19071897
self.assertEqual(len(mpp_set.htlcs), 1, f"should get only one htlc: {mpp_set.htlcs=}")

0 commit comments

Comments
 (0)