@@ -16,6 +16,7 @@ import (
1616 "github.com/lightningnetwork/lnd/fn"
1717 "github.com/lightningnetwork/lnd/kvdb/etcd"
1818 "github.com/lightningnetwork/lnd/lnrpc"
19+ "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
1920 "github.com/lightningnetwork/lnd/lnrpc/routerrpc"
2021 "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
2122 "github.com/lightningnetwork/lnd/lntest/node"
@@ -2183,6 +2184,39 @@ func (h *HarnessTest) ReceiveHtlcInterceptor(
21832184 return nil
21842185}
21852186
2187+ // ReceiveInvoiceAcceptor waits until a message is received on the invoice
2188+ // acceptor interceptor stream or the timeout is reached.
2189+ func (h * HarnessTest ) ReceiveInvoiceAcceptor (
2190+ stream rpc.InvoiceAcceptorClient ) * invoicesrpc.InvoiceAcceptorRequest {
2191+
2192+ chanMsg := make (chan * invoicesrpc.InvoiceAcceptorRequest )
2193+ errChan := make (chan error )
2194+ go func () {
2195+ // Consume one message. This will block until the message is
2196+ // received.
2197+ resp , err := stream .Recv ()
2198+ if err != nil {
2199+ errChan <- err
2200+ return
2201+ }
2202+ chanMsg <- resp
2203+ }()
2204+
2205+ select {
2206+ case <- time .After (DefaultTimeout ):
2207+ require .Fail (h , "timeout" , "timeout invoice acceptor" )
2208+
2209+ case err := <- errChan :
2210+ require .Failf (h , "err from stream" ,
2211+ "received err from stream: %v" , err )
2212+
2213+ case updateMsg := <- chanMsg :
2214+ return updateMsg
2215+ }
2216+
2217+ return nil
2218+ }
2219+
21862220// ReceiveChannelEvent waits until a message is received from the
21872221// ChannelEventsClient stream or the timeout is reached.
21882222func (h * HarnessTest ) ReceiveChannelEvent (
0 commit comments