From dbf7e4525a61156b13770351f24d9c9427103ae7 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 24 Apr 2018 20:34:30 -0700 Subject: [PATCH] lntest: ensure we always cancel active streaming notifications --- channeldb/db.go | 6 ++++++ channeldb/payments.go | 2 +- lntest/node.go | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/channeldb/db.go b/channeldb/db.go index 076b1c2c..911e40db 100644 --- a/channeldb/db.go +++ b/channeldb/db.go @@ -47,6 +47,12 @@ var ( number: 1, migration: migrateNodeAndEdgeUpdateIndex, }, + { + // The DB version that added the invoice event time + // series. + number: 2, + migration: migrateInvoiceTimeSeries, + }, } // Big endian is the preferred byte order, due to cursor scans over diff --git a/channeldb/payments.go b/channeldb/payments.go index 2a0cd914..0e5f47b9 100644 --- a/channeldb/payments.go +++ b/channeldb/payments.go @@ -177,7 +177,7 @@ func deserializeOutgoingPayment(r io.Reader) (*OutgoingPayment, error) { if err != nil { return nil, err } - p.Invoice = *inv + p.Invoice = inv if _, err := r.Read(scratch[:]); err != nil { return nil, err diff --git a/lntest/node.go b/lntest/node.go index d8ccfa4a..809092eb 100644 --- a/lntest/node.go +++ b/lntest/node.go @@ -639,9 +639,9 @@ func (hn *HarnessNode) lightningNetworkWatcher() { go func() { defer hn.wg.Done() - ctxb := context.Background() req := &lnrpc.GraphTopologySubscription{} - topologyClient, err := hn.SubscribeChannelGraph(ctxb, req) + ctx, cancelFunc := context.WithCancel(context.Background()) + topologyClient, err := hn.SubscribeChannelGraph(ctx, req) if err != nil { // We panic here in case of an error as failure to // create the topology client will cause all subsequent @@ -650,6 +650,8 @@ func (hn *HarnessNode) lightningNetworkWatcher() { "client: %v", err)) } + defer cancelFunc() + for { update, err := topologyClient.Recv() if err == io.EOF {