From 7a6fb694c8b16b735dce19523c71efab9a844107 Mon Sep 17 00:00:00 2001 From: ScuttoZ Date: Fri, 19 Jun 2026 14:33:05 +0200 Subject: [PATCH] flake: fix in-flight statuses causing flakyness by waiting for all xpay-n layers to be removed from askrene before checking settlement outcome --- tests/test_pay.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_pay.py b/tests/test_pay.py index 0f357547ae76..04786bc5b580 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -5312,6 +5312,17 @@ def test_sendpay_grouping(node_factory, bitcoind): # And finally we should have all 3 attempts to pay the invoice pays = l1.rpc.listpays()['pays'] assert(len(pays) == 3) + + # xpay returns the failure to the caller before it finishes cleaning up + # the payment, so a failed attempt can still be reported as 'pending' + # (attempt_ongoing() -> true) right after the rpc returns. Each xpay payment + # owns a private "xpay-" askrene layer which is removed in that same cleanup, + # so wait for them all to disappear before checking the exact statuses. + # If payment hangs indefinetly, the default timeout will fail the test + # (60s/180s if SLOW_MACHINE=1). + wait_for(lambda: not any(layer['layer'].startswith('xpay-') + for layer in l1.rpc.askrene_listlayers()['layers'])) + pays = l1.rpc.listpays()['pays'] assert([p['status'] for p in pays] == ['failed', 'failed', 'complete'])