3
3
package systemtests
4
4
5
5
import (
6
+ "bytes"
6
7
"context"
8
+ "os"
7
9
"testing"
8
10
9
- "github.com/fullstorydev/grpcurl"
11
+ "github.com/fullstorydev/grpcurl" //nolint:staticcheck: input in grpcurl
10
12
"github.com/jhump/protoreflect/grpcreflect"
11
13
"github.com/stretchr/testify/require"
12
14
"google.golang.org/grpc"
@@ -29,3 +31,54 @@ func TestGRPCReflection(t *testing.T) {
29
31
require .Greater (t , len (services ), 0 )
30
32
require .Contains (t , services , "cosmos.staking.v1beta1.Query" )
31
33
}
34
+
35
+ func TestGRPCQuery (t * testing.T ) {
36
+ systest .Sut .ResetChain (t )
37
+ systest .Sut .StartChain (t )
38
+
39
+ ctx := context .Background ()
40
+ grpcClient , err := grpc .NewClient ("localhost:9090" , grpc .WithTransportCredentials (insecure .NewCredentials ()))
41
+ require .NoError (t , err )
42
+
43
+ descSource := grpcurl .DescriptorSourceFromServer (ctx , grpcreflect .NewClientAuto (ctx , grpcClient ))
44
+
45
+ rf , formatter , err := grpcurl .RequestParserAndFormatter (grpcurl .FormatText , descSource , os .Stdin , grpcurl.FormatOptions {})
46
+ require .NoError (t , err )
47
+
48
+ buf := & bytes.Buffer {}
49
+ h := & grpcurl.DefaultEventHandler {
50
+ Out : buf ,
51
+ Formatter : formatter ,
52
+ VerbosityLevel : 0 ,
53
+ }
54
+
55
+ err = grpcurl .InvokeRPC (ctx , descSource , grpcClient , "cosmos.staking.v1beta1.Query/Params" , nil , h , rf .Next )
56
+ require .NoError (t , err )
57
+ require .Contains (t , buf .String (), "max_validators" )
58
+ }
59
+
60
+ func TestGRPCQueryAutoCLIOptions (t * testing.T ) {
61
+ t .Skip () // TODO(@julienrbrt): re-add autocli query in v2 in follow-up
62
+
63
+ systest .Sut .ResetChain (t )
64
+ systest .Sut .StartChain (t )
65
+
66
+ ctx := context .Background ()
67
+ grpcClient , err := grpc .NewClient ("localhost:9090" , grpc .WithTransportCredentials (insecure .NewCredentials ()))
68
+ require .NoError (t , err )
69
+
70
+ descSource := grpcurl .DescriptorSourceFromServer (ctx , grpcreflect .NewClientAuto (ctx , grpcClient ))
71
+
72
+ rf , formatter , err := grpcurl .RequestParserAndFormatter (grpcurl .FormatText , descSource , os .Stdin , grpcurl.FormatOptions {})
73
+ require .NoError (t , err )
74
+
75
+ buf := & bytes.Buffer {}
76
+ h := & grpcurl.DefaultEventHandler {
77
+ Out : buf ,
78
+ Formatter : formatter ,
79
+ VerbosityLevel : 0 ,
80
+ }
81
+
82
+ err = grpcurl .InvokeRPC (ctx , descSource , grpcClient , "cosmos.autocli.v1.Query/AppOptions" , nil , h , rf .Next )
83
+ require .NoError (t , err )
84
+ }
0 commit comments