From e3522bc5c1fc0db0760bb6d74d4f0f1dc580ec1b Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 13 Jan 2025 08:54:18 +0100 Subject: [PATCH] updates --- .../api/grpc/gogoreflection/serverreflection.go | 3 ++- tests/systemtests/grpc_test.go | 16 ++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/server/v2/api/grpc/gogoreflection/serverreflection.go b/server/v2/api/grpc/gogoreflection/serverreflection.go index 9f27f5f583f..e8d4b7faac0 100644 --- a/server/v2/api/grpc/gogoreflection/serverreflection.go +++ b/server/v2/api/grpc/gogoreflection/serverreflection.go @@ -474,7 +474,8 @@ func (s *serverReflectionServer) getServices(messages []string) (svcs []string, svc, ok := findServiceForMessage(registry, md.(protoreflect.MessageDescriptor)) if !ok { - s.log.Warn(fmt.Sprintf("unable to find service for message %s", messageName)) + // if a service is not found for the message, simply skip + // this is likely the message isn't part of a service and using appmodulev2.Handler instead. continue } diff --git a/tests/systemtests/grpc_test.go b/tests/systemtests/grpc_test.go index 60745139237..444b5405f81 100644 --- a/tests/systemtests/grpc_test.go +++ b/tests/systemtests/grpc_test.go @@ -17,31 +17,23 @@ import ( systest "cosmossdk.io/systemtests" ) -func TestGRPCReflection(t *testing.T) { +func TestGRPC(t *testing.T) { systest.Sut.ResetChain(t) systest.Sut.StartChain(t) ctx := context.Background() grpcClient, err := grpc.NewClient("localhost:9090", grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) + defer grpcClient.Close() + // test grpc reflection descSource := grpcurl.DescriptorSourceFromServer(ctx, grpcreflect.NewClientAuto(ctx, grpcClient)) services, err := grpcurl.ListServices(descSource) require.NoError(t, err) require.Greater(t, len(services), 0) require.Contains(t, services, "cosmos.staking.v1beta1.Query") -} - -func TestGRPCQuery(t *testing.T) { - systest.Sut.ResetChain(t) - systest.Sut.StartChain(t) - - ctx := context.Background() - grpcClient, err := grpc.NewClient("localhost:9090", grpc.WithTransportCredentials(insecure.NewCredentials())) - require.NoError(t, err) - - descSource := grpcurl.DescriptorSourceFromServer(ctx, grpcreflect.NewClientAuto(ctx, grpcClient)) + // test query invokation rf, formatter, err := grpcurl.RequestParserAndFormatter(grpcurl.FormatText, descSource, os.Stdin, grpcurl.FormatOptions{}) require.NoError(t, err)