Skip to content

Commit 90bca10

Browse files
committed
lntest: retry finding the payment from ListPayments
1 parent 4506fd3 commit 90bca10

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

lntest/harness_assertion.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,23 +1640,18 @@ func (h *HarnessTest) AssertNumHTLCsAndStage(hn *node.HarnessNode,
16401640
// findPayment queries the payment from the node's ListPayments which matches
16411641
// the specified preimage hash.
16421642
func (h *HarnessTest) findPayment(hn *node.HarnessNode,
1643-
paymentHash string) *lnrpc.Payment {
1643+
paymentHash string) (*lnrpc.Payment, error) {
16441644

16451645
req := &lnrpc.ListPaymentsRequest{IncludeIncomplete: true}
16461646
paymentsResp := hn.RPC.ListPayments(req)
16471647

16481648
for _, p := range paymentsResp.Payments {
1649-
if p.PaymentHash != paymentHash {
1650-
continue
1649+
if p.PaymentHash == paymentHash {
1650+
return p, nil
16511651
}
1652-
1653-
return p
16541652
}
16551653

1656-
require.Failf(h, "payment not found", "payment %v cannot be found",
1657-
paymentHash)
1658-
1659-
return nil
1654+
return nil, fmt.Errorf("payment %v cannot be found", paymentHash)
16601655
}
16611656

16621657
// PaymentCheck is a function that checks a payment for a specific condition.
@@ -1674,7 +1669,11 @@ func (h *HarnessTest) AssertPaymentStatus(hn *node.HarnessNode,
16741669
payHash := preimage.Hash()
16751670

16761671
err := wait.NoError(func() error {
1677-
p := h.findPayment(hn, payHash.String())
1672+
p, err := h.findPayment(hn, payHash.String())
1673+
if err != nil {
1674+
return err
1675+
}
1676+
16781677
if status == p.Status {
16791678
target = p
16801679
return nil
@@ -1713,7 +1712,11 @@ func (h *HarnessTest) AssertPaymentFailureReason(hn *node.HarnessNode,
17131712

17141713
payHash := preimage.Hash()
17151714
err := wait.NoError(func() error {
1716-
p := h.findPayment(hn, payHash.String())
1715+
p, err := h.findPayment(hn, payHash.String())
1716+
if err != nil {
1717+
return err
1718+
}
1719+
17171720
if reason == p.FailureReason {
17181721
return nil
17191722
}

0 commit comments

Comments
 (0)