diff --git a/lnd_test.go b/lnd_test.go index 240d99ce..47c07aa8 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -4302,10 +4302,12 @@ func testInvoiceSubscriptions(net *lntest.NetworkHarness, t *harnessTest) { // Create a new invoice subscription client for Bob, the notification // should be dispatched shortly below. req := &lnrpc.InvoiceSubscription{} - bobInvoiceSubscription, err := net.Bob.SubscribeInvoices(ctxb, req) + ctx, cancelFunc := context.WithCancel(context.Background()) + bobInvoiceSubscription, err := net.Bob.SubscribeInvoices(ctx, req) if err != nil { t.Fatalf("unable to subscribe to bob's invoice updates: %v", err) } + defer cancelFunc() quit := make(chan struct{}) updateSent := make(chan struct{}) @@ -5986,7 +5988,8 @@ func subscribeGraphNotifications(t *harnessTest, ctxb context.Context, // We'll first start by establishing a notification client which will // send us notifications upon detected changes in the channel graph. req := &lnrpc.GraphTopologySubscription{} - topologyClient, err := node.SubscribeChannelGraph(ctxb, req) + ctx, cancelFunc := context.WithCancel(context.Background()) + topologyClient, err := node.SubscribeChannelGraph(ctx, req) if err != nil { t.Fatalf("unable to create topology client: %v", err) } @@ -5997,6 +6000,8 @@ func subscribeGraphNotifications(t *harnessTest, ctxb context.Context, graphUpdates := make(chan *lnrpc.GraphTopologyUpdate, 20) go func() { for { + defer cancelFunc() + select { case <-quit: return