lntest: add HtlcModifier support to node RPC harness

This commit enhances the itest LND node harness to include support for
the new `HtlcModifier` RPC endpoint.
At the same time we move another method to the correct file.
This commit is contained in:
ffranr authored and Oliver Gugger committed 2024-09-19 09:21:38 +02:00
1 parent 1975fa60e2
commit 0c6a1558d5
3 files changed
+65 -14

No files matched your search

+12 -12
View File
@@ -5,7 +5,6 @@ import (
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
)
// =====================
@@ -84,18 +83,19 @@ func (h *HarnessRPC) SubscribeSingleInvoice(rHash []byte) SingleInvoiceClient {
return client
}
type TrackPaymentClient routerrpc.Router_TrackPaymentV2Client
type InvoiceHtlcModifierClient invoicesrpc.Invoices_HtlcModifierClient
// TrackPaymentV2 creates a subscription client for given invoice and
// asserts its creation.
func (h *HarnessRPC) TrackPaymentV2(payHash []byte) TrackPaymentClient {
req := &routerrpc.TrackPaymentRequest{PaymentHash: payHash}
// InvoiceHtlcModifier makes an RPC call to the node's RouterClient and asserts.
func (h *HarnessRPC) InvoiceHtlcModifier() (InvoiceHtlcModifierClient,
context.CancelFunc) {
// TrackPaymentV2 needs to have the context alive for the entire test
// case as the returned client will be used for send and receive events
// stream. Thus we use runCtx here instead of a timeout context.
client, err := h.Router.TrackPaymentV2(h.runCtx, req)
h.NoError(err, "TrackPaymentV2")
// InvoiceHtlcModifier needs to have the context alive for the entire
// test case as the returned client will be used for send and receive
// events stream. Therefore, we use cancel context here instead of a
// timeout context.
ctxt, cancel := context.WithCancel(h.runCtx)
resp, err := h.Invoice.HtlcModifier(ctxt)
h.NoError(err, "InvoiceHtlcModifier")
return client
return resp, cancel
}
+16
View File
@@ -267,3 +267,19 @@ func (h *HarnessRPC) TrackPayments(
return resp
}
type TrackPaymentClient routerrpc.Router_TrackPaymentV2Client
// TrackPaymentV2 creates a subscription client for given invoice and
// asserts its creation.
func (h *HarnessRPC) TrackPaymentV2(payHash []byte) TrackPaymentClient {
req := &routerrpc.TrackPaymentRequest{PaymentHash: payHash}
// TrackPaymentV2 needs to have the context alive for the entire test
// case as the returned client will be used for send and receive events
// stream. Thus we use runCtx here instead of a timeout context.
client, err := h.Router.TrackPaymentV2(h.runCtx, req)
h.NoError(err, "TrackPaymentV2")
return client
}