From b95d48971dde344ee4f7df8b1294e1b2ed628b03 Mon Sep 17 00:00:00 2001 From: MPins Date: Sun, 24 Nov 2024 08:57:36 -0300 Subject: [PATCH] lntest: add the function RPC call to asserts errors on AddInvoice --- lntest/rpc/lnd.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lntest/rpc/lnd.go b/lntest/rpc/lnd.go index c578d0525..1a49cd18b 100644 --- a/lntest/rpc/lnd.go +++ b/lntest/rpc/lnd.go @@ -293,6 +293,16 @@ func (h *HarnessRPC) AddInvoice(req *lnrpc.Invoice) *lnrpc.AddInvoiceResponse { return invoice } +// AddInvoiceAssertErr makes a RPC call to AddInvoice and asserts an error +// has returned with a specific error message. +func (h *HarnessRPC) AddInvoiceAssertErr(req *lnrpc.Invoice, errStr string) { + ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout) + defer cancel() + + _, err := h.LN.AddInvoice(ctxt, req) + require.ErrorContains(h, err, errStr) +} + // AbandonChannel makes a RPC call to AbandonChannel and asserts. func (h *HarnessRPC) AbandonChannel( req *lnrpc.AbandonChannelRequest) *lnrpc.AbandonChannelResponse {