From f52ee770f427313b6d8dbc20eb7284c8e6fa18d0 Mon Sep 17 00:00:00 2001 From: Matheus Degiovani Date: Thu, 9 Apr 2020 08:29:48 -0300 Subject: [PATCH] lntest: use ctx when not using macaroons This forces the Dial attempt to succeed or fail before proceeding with node setup. We also log on the node a failure to establish the graph subscription before panicking so that we can more easily find issues. --- lntest/node.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lntest/node.go b/lntest/node.go index 0f864f2a..00ac34a6 100644 --- a/lntest/node.go +++ b/lntest/node.go @@ -737,14 +737,15 @@ func (hn *HarnessNode) ConnectRPCWithMacaroon(mac *macaroon.Macaroon) ( } opts = append(opts, grpc.WithTransportCredentials(tlsCreds)) + ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout) + defer cancel() + if mac == nil { - return grpc.Dial(hn.Cfg.RPCAddr(), opts...) + return grpc.DialContext(ctx, hn.Cfg.RPCAddr(), opts...) } macCred := macaroons.NewMacaroonCredential(mac) opts = append(opts, grpc.WithPerRPCCredentials(macCred)) - ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout) - defer cancel() return grpc.DialContext(ctx, hn.Cfg.RPCAddr(), opts...) }