Merge pull request #8836 from hieblmi/payment-failure-reason-cancel

routing: add payment failure reason `FailureReasonCancel`
This commit is contained in:
Olaoluwa Osuntokun authored and GitHub committed 2024-08-01 16:52:06 -07:00
commit c46b1a467a
13 files changed
+596 -398

No files matched your search

+18
View File
@@ -1639,6 +1639,24 @@ func (h *HarnessTest) AssertPaymentStatus(hn *node.HarnessNode,
return target
}
// AssertPaymentFailureReason asserts that the given node lists a payment with
// the given preimage which has the expected failure reason.
func (h *HarnessTest) AssertPaymentFailureReason(hn *node.HarnessNode,
preimage lntypes.Preimage, reason lnrpc.PaymentFailureReason) {
payHash := preimage.Hash()
err := wait.NoError(func() error {
p := h.findPayment(hn, payHash.String())
if reason == p.FailureReason {
return nil
}
return fmt.Errorf("payment: %v failure reason not match, "+
"want %s got %s", payHash, reason, p.Status)
}, DefaultTimeout)
require.NoError(h, err, "timeout checking payment failure reason")
}
// AssertActiveNodesSynced asserts all active nodes have synced to the chain.
func (h *HarnessTest) AssertActiveNodesSynced() {
for _, node := range h.manager.activeNodes {
+16 -1
View File
@@ -36,7 +36,7 @@ func (h *HarnessRPC) SendPayment(
req *routerrpc.SendPaymentRequest) PaymentClient {
// SendPayment needs to have the context alive for the entire test case
// as the router relies on the context to propagate HTLCs. Thus we use
// as the router relies on the context to propagate HTLCs. Thus, we use
// runCtx here instead of a timeout context.
stream, err := h.Router.SendPaymentV2(h.runCtx, req)
h.NoError(err, "SendPaymentV2")
@@ -44,6 +44,21 @@ func (h *HarnessRPC) SendPayment(
return stream
}
// SendPaymentWithContext sends a payment using the given node and payment
// request and does so with the passed in context.
func (h *HarnessRPC) SendPaymentWithContext(context context.Context,
req *routerrpc.SendPaymentRequest) PaymentClient {
require.NotNil(h.T, context, "context must not be nil")
// SendPayment needs to have the context alive for the entire test case
// as the router relies on the context to propagate HTLCs.
stream, err := h.Router.SendPaymentV2(context, req)
h.NoError(err, "SendPaymentV2")
return stream
}
type HtlcEventsClient routerrpc.Router_SubscribeHtlcEventsClient
// SubscribeHtlcEvents makes a subscription to the HTLC events and returns a