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