test: ensure we always cancel active streaming notifications
This commit is contained in:
parent
dbf7e4525a
commit
29a27bbc3a
@ -4302,10 +4302,12 @@ func testInvoiceSubscriptions(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Create a new invoice subscription client for Bob, the notification
|
// Create a new invoice subscription client for Bob, the notification
|
||||||
// should be dispatched shortly below.
|
// should be dispatched shortly below.
|
||||||
req := &lnrpc.InvoiceSubscription{}
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("unable to subscribe to bob's invoice updates: %v", err)
|
t.Fatalf("unable to subscribe to bob's invoice updates: %v", err)
|
||||||
}
|
}
|
||||||
|
defer cancelFunc()
|
||||||
|
|
||||||
quit := make(chan struct{})
|
quit := make(chan struct{})
|
||||||
updateSent := 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
|
// We'll first start by establishing a notification client which will
|
||||||
// send us notifications upon detected changes in the channel graph.
|
// send us notifications upon detected changes in the channel graph.
|
||||||
req := &lnrpc.GraphTopologySubscription{}
|
req := &lnrpc.GraphTopologySubscription{}
|
||||||
topologyClient, err := node.SubscribeChannelGraph(ctxb, req)
|
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||||
|
topologyClient, err := node.SubscribeChannelGraph(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create topology client: %v", err)
|
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)
|
graphUpdates := make(chan *lnrpc.GraphTopologyUpdate, 20)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
defer cancelFunc()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-quit:
|
case <-quit:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user