itest: payment failure reason canceled

This commit is contained in:
Slyghtning
2024-07-26 17:11:59 +02:00
parent 653226d29c
commit 0273eac4b2
4 changed files with 171 additions and 1 deletions

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 {

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