From 8e3e785f5c31215fa9f5cec03a03245b136b5842 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Mon, 10 Apr 2023 19:26:59 +0900 Subject: [PATCH] Revert "fix: return nil where the parent not exists in x/collection Query/Parent (#955)" This reverts commit d562b43025ce4c354e87f6b0ed60a09ec594e9a7. --- x/collection/keeper/grpc_query.go | 2 +- x/collection/keeper/grpc_query_test.go | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) 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) }) }