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.
This commit is contained in:
Matheus Degiovani 2020-04-09 08:29:48 -03:00
parent 19873f721f
commit f52ee770f4

@ -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...)
}