Skip to content

Commit

Permalink
Revert "fix: return nil where the parent not exists in x/collection Q…
Browse files Browse the repository at this point in the history
…uery/Parent (Finschia#955)"

This reverts commit d562b43.
  • Loading branch information
0Tech committed Apr 10, 2023
1 parent 0c74e6f commit 8e3e785
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion x/collection/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 5 additions & 9 deletions x/collection/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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 {
Expand All @@ -830,6 +825,7 @@ func (s *KeeperTestSuite) TestQueryParent() {
return
}
s.Require().NoError(err)
s.Require().NotNil(res)
tc.postTest(res)
})
}
Expand Down

0 comments on commit 8e3e785

Please sign in to comment.