Skip to content

Commit

Permalink
Increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
0Tech committed Apr 12, 2023
1 parent 46fa27b commit 80c52a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions x/collection/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,10 @@ func (s queryServer) Root(c context.Context, req *collection.QueryRootRequest) (
}

func (s queryServer) HasParent(c context.Context, req *collection.QueryHasParentRequest) (*collection.QueryHasParentResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

ctx := sdk.UnwrapSDKContext(c)

if err := s.validateGetParentVariants(ctx, req); err != nil {
Expand All @@ -511,6 +515,10 @@ func (s queryServer) HasParent(c context.Context, req *collection.QueryHasParent
}

func (s queryServer) Parent(c context.Context, req *collection.QueryParentRequest) (*collection.QueryParentResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

ctx := sdk.UnwrapSDKContext(c)

if err := s.validateGetParentVariants(ctx, req); err != nil {
Expand All @@ -536,10 +544,6 @@ type parentRequest interface {
}

func (s queryServer) validateGetParentVariants(ctx sdk.Context, req parentRequest) error {
if req == nil {
return status.Error(codes.InvalidArgument, "empty request")
}

if err := collection.ValidateContractID(req.GetContractId()); err != nil {
return status.Error(codes.InvalidArgument, err.Error())
}
Expand Down
4 changes: 4 additions & 0 deletions x/token/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ func (s *KeeperTestSuite) TestQueryHoldersByOperator() {
"invalid operator": {
contractID: s.contractID,
},
"class not found": {
contractID: "fee1dead",
operator: s.operator,
},
}

for name, tc := range testCases {
Expand Down

0 comments on commit 80c52a6

Please sign in to comment.