Skip to content

Commit aaefc60

Browse files
Lagrang3ddustin
authored andcommitted
listsendpays: discriminate ongoing payment by groupid
A payment attempt in listpays is defined as pair (payment hash, group id). If we query xpay for ongoing payments we must discriminate using both values. Fixes flaky test tests/test_pay.py:test_sendpay_grouping ``` FAILED tests/test_pay.py::test_sendpay_grouping - AssertionError: assert ['pending', 'pending', 'complete'] == ['failed', 'failed', 'complete'] ``` Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
1 parent c17a48f commit aaefc60

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

plugins/xpay/listpays.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ static void add_new_entry(struct plugin *plugin,
159159

160160
if (pm->state & PAYMENT_COMPLETE)
161161
json_add_string(ret, "status", "complete");
162-
else if (pm->state & PAYMENT_PENDING || attempt_ongoing(plugin, pm->payment_hash))
162+
else if (pm->state & PAYMENT_PENDING ||
163+
attempt_ongoing(plugin, pm->payment_hash, pm->sortkey.groupid))
163164
json_add_string(ret, "status", "pending");
164165
else
165166
json_add_string(ret, "status", "failed");

plugins/xpay/xpay.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,13 +2510,15 @@ static struct payment *new_payment(const tal_t *ctx,
25102510
return payment;
25112511
}
25122512

2513-
bool attempt_ongoing(struct plugin *plugin, const struct sha256 *payment_hash)
2513+
bool attempt_ongoing(struct plugin *plugin, const struct sha256 *payment_hash,
2514+
u64 groupid)
25142515
{
25152516
struct xpay *xpay = xpay_of(plugin);
25162517
const struct payment *payment;
25172518

25182519
list_for_each(&xpay->payments, payment, list) {
2519-
if (sha256_eq(&payment->payment_hash, payment_hash))
2520+
if (sha256_eq(&payment->payment_hash, payment_hash) &&
2521+
payment->group_id == groupid)
25202522
return true;
25212523
}
25222524
return false;

plugins/xpay/xpay.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ struct plugin;
77
struct sha256;
88

99
/* Are we still attempting this payment? If so, we won't list is as failed. */
10-
bool attempt_ongoing(struct plugin *plugin, const struct sha256 *payment_hash);
10+
bool attempt_ongoing(struct plugin *plugin, const struct sha256 *payment_hash,
11+
u64 groupid);
1112

1213
#endif /* LIGHTNING_PLUGINS_XPAY_XPAY_H */

0 commit comments

Comments
 (0)