feat: add query groups in x/group (#14879)

Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
This commit is contained in:
atheeshp
2023-02-03 10:00:46 +00:00
committed by GitHub
co-authored by Likhita Polavarapu
parent bdf4c76daf
commit a2797c8cd4
11 changed files with 2255 additions and 302 deletions
+49
View File
@@ -147,6 +147,55 @@ func (s *E2ETestSuite) TestQueryGroupsByMembers() {
}
}
func (s *E2ETestSuite) TestQueryGroups() {
val := s.network.Validators[0]
clientCtx := val.ClientCtx
require := s.Require()
testCases := []struct {
name string
args []string
expectErr bool
expectErrMsg string
numItems int
expectGroups []*group.GroupInfo
}{
{
name: "valid req",
args: []string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
expectErr: false,
numItems: 5,
},
{
name: "valid req with pagination",
args: []string{
"--limit=2",
fmt.Sprintf("--%s=json", flags.FlagOutput),
},
expectErr: false,
numItems: 2,
},
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := client.QueryGroupsCmd()
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
require.Contains(out.String(), tc.expectErrMsg)
} else {
require.NoError(err, out.String())
var resp group.QueryGroupsResponse
val.ClientCtx.Codec.MustUnmarshalJSON(out.Bytes(), &resp)
require.Len(resp.Groups, tc.numItems)
}
})
}
}
func (s *E2ETestSuite) TestQueryGroupMembers() {
val := s.network.Validators[0]
clientCtx := val.ClientCtx