diff --git a/x/collection/keeper/grpc_query.go b/x/collection/keeper/grpc_query.go index 131fb14485..6a282e9a89 100644 --- a/x/collection/keeper/grpc_query.go +++ b/x/collection/keeper/grpc_query.go @@ -534,7 +534,7 @@ func (s queryServer) Parent(c context.Context, req *collection.QueryParentReques parent, err := s.keeper.GetParent(ctx, req.ContractId, req.TokenId) if err != nil { - return nil, nil + return nil, err } token, err := s.keeper.GetNFT(ctx, req.ContractId, *parent) diff --git a/x/collection/keeper/grpc_query_test.go b/x/collection/keeper/grpc_query_test.go index a5c6f25bc6..8d8966268c 100644 --- a/x/collection/keeper/grpc_query_test.go +++ b/x/collection/keeper/grpc_query_test.go @@ -790,18 +790,9 @@ func (s *KeeperTestSuite) TestQueryParent() { tokenID: tokenID, valid: true, postTest: func(res *collection.QueryParentResponse) { - s.Require().NotNil(res) s.Require().Equal(collection.NewNFTID(s.nftClassID, 1), res.Parent.TokenId) }, }, - "valid request with no parent": { - contractID: s.contractID, - tokenID: collection.NewNFTID(s.nftClassID, 1), - valid: true, - postTest: func(res *collection.QueryParentResponse) { - s.Require().Nil(res) - }, - }, "invalid contract id": { tokenID: tokenID, }, @@ -816,6 +807,10 @@ func (s *KeeperTestSuite) TestQueryParent() { contractID: s.contractID, tokenID: collection.NewNFTID("deadbeef", 1), }, + "no parent": { + contractID: s.contractID, + tokenID: collection.NewNFTID(s.nftClassID, 1), + }, } for name, tc := range testCases { @@ -830,6 +825,7 @@ func (s *KeeperTestSuite) TestQueryParent() { return } s.Require().NoError(err) + s.Require().NotNil(res) tc.postTest(res) }) }