From ed299c6297fa9519a2fe7749ad5ef208dce73037 Mon Sep 17 00:00:00 2001 From: romelukaku Date: Fri, 29 Apr 2022 11:58:58 +0700 Subject: [PATCH 1/7] change Query/DenomTrace gRPC --- docs/client/swagger-ui/swagger.yaml | 4 +- docs/ibc/proto-docs.md | 4 +- modules/apps/transfer/client/cli/query.go | 2 +- modules/apps/transfer/keeper/grpc_query.go | 11 ++- .../apps/transfer/keeper/grpc_query_test.go | 8 +- modules/apps/transfer/types/query.pb.go | 95 +++++++++---------- modules/apps/transfer/types/query.pb.gw.go | 18 ++-- .../ibc/applications/transfer/v1/query.proto | 4 +- 8 files changed, 75 insertions(+), 71 deletions(-) diff --git a/docs/client/swagger-ui/swagger.yaml b/docs/client/swagger-ui/swagger.yaml index 5feb43dd2a5..a86dc9d0ce8 100644 --- a/docs/client/swagger-ui/swagger.yaml +++ b/docs/client/swagger-ui/swagger.yaml @@ -178,7 +178,7 @@ paths: format: boolean tags: - Query - '/ibc/apps/transfer/v1/denom_traces/{hash}': + '/ibc/apps/transfer/v1/denom_traces/{denom}': get: summary: DenomTrace queries a denomination trace information. operationId: DenomTrace @@ -234,7 +234,7 @@ paths: type: string format: byte parameters: - - name: hash + - name: denom description: hash (in hex format) of the denomination trace information. in: path required: true diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index cf411ade14c..f571baa5ed1 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -1863,7 +1863,7 @@ method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `hash` | [string](#string) | | hash (in hex format) of the denomination trace information. | +| `denom` | [string](#string) | | hash (in hex format) of the denomination trace information. | @@ -1957,7 +1957,7 @@ Query provides defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `DenomTrace` | [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest) | [QueryDenomTraceResponse](#ibc.applications.transfer.v1.QueryDenomTraceResponse) | DenomTrace queries a denomination trace information. | GET|/ibc/apps/transfer/v1/denom_traces/{hash}| +| `DenomTrace` | [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest) | [QueryDenomTraceResponse](#ibc.applications.transfer.v1.QueryDenomTraceResponse) | DenomTrace queries a denomination trace information. | GET|/ibc/apps/transfer/v1/denom_traces/{denom}| | `DenomTraces` | [QueryDenomTracesRequest](#ibc.applications.transfer.v1.QueryDenomTracesRequest) | [QueryDenomTracesResponse](#ibc.applications.transfer.v1.QueryDenomTracesResponse) | DenomTraces queries all denomination traces. | GET|/ibc/apps/transfer/v1/denom_traces| | `Params` | [QueryParamsRequest](#ibc.applications.transfer.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.transfer.v1.QueryParamsResponse) | Params queries all parameters of the ibc-transfer module. | GET|/ibc/apps/transfer/v1/params| | `DenomHash` | [QueryDenomHashRequest](#ibc.applications.transfer.v1.QueryDenomHashRequest) | [QueryDenomHashResponse](#ibc.applications.transfer.v1.QueryDenomHashResponse) | DenomHash queries a denomination hash information. | GET|/ibc/apps/transfer/v1/denom_hashes/{trace}| diff --git a/modules/apps/transfer/client/cli/query.go b/modules/apps/transfer/client/cli/query.go index 3239b154377..b81c8addfa3 100644 --- a/modules/apps/transfer/client/cli/query.go +++ b/modules/apps/transfer/client/cli/query.go @@ -27,7 +27,7 @@ func GetCmdQueryDenomTrace() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) req := &types.QueryDenomTraceRequest{ - Hash: args[0], + Denom: args[0], } res, err := queryClient.DenomTrace(cmd.Context(), req) diff --git a/modules/apps/transfer/keeper/grpc_query.go b/modules/apps/transfer/keeper/grpc_query.go index e0b16c6a761..cfcc30d9e0c 100644 --- a/modules/apps/transfer/keeper/grpc_query.go +++ b/modules/apps/transfer/keeper/grpc_query.go @@ -3,6 +3,7 @@ package keeper import ( "context" "fmt" + "strings" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" @@ -22,9 +23,13 @@ func (q Keeper) DenomTrace(c context.Context, req *types.QueryDenomTraceRequest) return nil, status.Error(codes.InvalidArgument, "empty request") } - hash, err := types.ParseHexHash(req.Hash) + if !strings.HasPrefix(req.Denom, "ibc/") { + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom with no ibc prefix %s", req.Denom)) + } + + hash, err := types.ParseHexHash(req.Denom[4:]) if err != nil { - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash %s, %s", req.Hash, err)) + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash %s, %s", req.Denom[4:], err)) } ctx := sdk.UnwrapSDKContext(c) @@ -32,7 +37,7 @@ func (q Keeper) DenomTrace(c context.Context, req *types.QueryDenomTraceRequest) if !found { return nil, status.Error( codes.NotFound, - sdkerrors.Wrap(types.ErrTraceNotFound, req.Hash).Error(), + sdkerrors.Wrap(types.ErrTraceNotFound, req.Denom).Error(), ) } diff --git a/modules/apps/transfer/keeper/grpc_query_test.go b/modules/apps/transfer/keeper/grpc_query_test.go index 34563447b5f..5633dff6712 100644 --- a/modules/apps/transfer/keeper/grpc_query_test.go +++ b/modules/apps/transfer/keeper/grpc_query_test.go @@ -21,10 +21,10 @@ func (suite *KeeperTestSuite) TestQueryDenomTrace() { expPass bool }{ { - "invalid hex hash", + "invalid ibc denom", func() { req = &types.QueryDenomTraceRequest{ - Hash: "!@#!@#!", + Denom: "!@#!@#!", } }, false, @@ -35,7 +35,7 @@ func (suite *KeeperTestSuite) TestQueryDenomTrace() { expTrace.Path = "transfer/channelToA/transfer/channelToB" expTrace.BaseDenom = "uatom" req = &types.QueryDenomTraceRequest{ - Hash: expTrace.Hash().String(), + Denom: expTrace.IBCDenom(), } }, false, @@ -48,7 +48,7 @@ func (suite *KeeperTestSuite) TestQueryDenomTrace() { suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace) req = &types.QueryDenomTraceRequest{ - Hash: expTrace.Hash().String(), + Denom: expTrace.IBCDenom(), } }, true, diff --git a/modules/apps/transfer/types/query.pb.go b/modules/apps/transfer/types/query.pb.go index 024da758162..a05e34f5b4f 100644 --- a/modules/apps/transfer/types/query.pb.go +++ b/modules/apps/transfer/types/query.pb.go @@ -34,7 +34,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // method type QueryDenomTraceRequest struct { // hash (in hex format) of the denomination trace information. - Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` } func (m *QueryDenomTraceRequest) Reset() { *m = QueryDenomTraceRequest{} } @@ -70,9 +70,9 @@ func (m *QueryDenomTraceRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryDenomTraceRequest proto.InternalMessageInfo -func (m *QueryDenomTraceRequest) GetHash() string { +func (m *QueryDenomTraceRequest) GetDenom() string { if m != nil { - return m.Hash + return m.Denom } return "" } @@ -420,45 +420,44 @@ func init() { } var fileDescriptor_a638e2800a01538c = []byte{ - // 595 bytes of a gzipped FileDescriptorProto + // 592 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x6f, 0xd3, 0x30, - 0x1c, 0xad, 0x07, 0xab, 0x34, 0x17, 0x71, 0x30, 0x05, 0xaa, 0xa8, 0xca, 0xa6, 0xa8, 0x82, 0xd2, - 0x6d, 0x36, 0x69, 0x07, 0x5c, 0x38, 0x4d, 0x88, 0x3f, 0xb7, 0xad, 0x70, 0x82, 0x03, 0x72, 0x52, - 0x93, 0x46, 0x6a, 0xe3, 0x2c, 0x4e, 0x2b, 0x4d, 0x68, 0x17, 0x3e, 0x01, 0xd2, 0xbe, 0x02, 0x07, - 0x34, 0xf1, 0x21, 0x38, 0xee, 0x38, 0x89, 0x0b, 0x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0x84, 0xf7, 0x09, 0xfa, 0x0a, 0x60, 0x25, 0x13, 0x1f, 0x54, 0x6c, 0x72, - 0xba, 0x31, 0xe3, 0x71, 0x51, 0x98, 0x66, 0xdc, 0x92, 0x8c, 0x1b, 0xc8, 0xba, 0x9c, 0x31, 0x3a, - 0x05, 0xb0, 0xac, 0x76, 0x8a, 0x1e, 0x5e, 0x61, 0x5c, 0x2e, 0x52, 0x86, 0x5d, 0x00, 0xa1, 0xb9, - 0x35, 0x24, 0x37, 0x13, 0xd5, 0x97, 0x73, 0x53, 0xb1, 0x42, 0x67, 0x00, 0x6e, 0xcc, 0x32, 0x82, - 0x3a, 0x57, 0xf5, 0x21, 0x13, 0x40, 0x63, 0xaf, 0x18, 0x48, 0xd3, 0x6b, 0x4b, 0x7a, 0x3b, 0xa8, - 0xb5, 0xca, 0xba, 0x64, 0xc9, 0xc9, 0xb2, 0xa5, 0x85, 0x27, 0xfb, 0x87, 0xe7, 0x13, 0x13, 0x5c, - 0x4c, 0x4c, 0xf0, 0x67, 0x62, 0x82, 0xcf, 0x53, 0xb3, 0x74, 0x31, 0x35, 0x4b, 0x3f, 0xa7, 0x66, - 0xe9, 0xed, 0x13, 0xcf, 0x8f, 0xfb, 0x23, 0x07, 0xbb, 0x7c, 0x48, 0xf4, 0x23, 0xee, 0x3b, 0xee, - 0xae, 0xc7, 0xc9, 0xb8, 0x43, 0x86, 0xbc, 0x37, 0x1a, 0x30, 0xf1, 0xdf, 0x90, 0xf8, 0x38, 0x64, - 0xc2, 0x29, 0xcb, 0x27, 0xb8, 0xf3, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x16, 0x01, 0x88, 0xe2, 0x59, - 0x06, 0x00, 0x00, + 0x1c, 0xad, 0x07, 0xab, 0xb4, 0x5f, 0x11, 0x07, 0x53, 0xa0, 0x8a, 0xaa, 0x6c, 0x8a, 0x2a, 0xa8, + 0xca, 0x66, 0xd3, 0x76, 0xc0, 0x85, 0xd3, 0x84, 0xf8, 0x73, 0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0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -677,10 +676,10 @@ func (m *QueryDenomTraceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Hash))) + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) i-- dAtA[i] = 0xa } @@ -941,7 +940,7 @@ func (m *QueryDenomTraceRequest) Size() (n int) { } var l int _ = l - l = len(m.Hash) + l = len(m.Denom) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -1078,7 +1077,7 @@ func (m *QueryDenomTraceRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1106,7 +1105,7 @@ func (m *QueryDenomTraceRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Hash = string(dAtA[iNdEx:postIndex]) + m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/modules/apps/transfer/types/query.pb.gw.go b/modules/apps/transfer/types/query.pb.gw.go index 6f17d4dc055..85f159e7cc7 100644 --- a/modules/apps/transfer/types/query.pb.gw.go +++ b/modules/apps/transfer/types/query.pb.gw.go @@ -42,15 +42,15 @@ func request_Query_DenomTrace_0(ctx context.Context, marshaler runtime.Marshaler _ = err ) - val, ok = pathParams["hash"] + val, ok = pathParams["denom"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") } - protoReq.Hash, err = runtime.String(val) + protoReq.Denom, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) } msg, err := client.DenomTrace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -69,15 +69,15 @@ func local_request_Query_DenomTrace_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["hash"] + val, ok = pathParams["denom"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") } - protoReq.Hash, err = runtime.String(val) + protoReq.Denom, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) } msg, err := server.DenomTrace(ctx, &protoReq) @@ -404,7 +404,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_DenomTrace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "apps", "transfer", "v1", "denom_traces", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_DenomTrace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "apps", "transfer", "v1", "denom_traces", "denom"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_DenomTraces_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "apps", "transfer", "v1", "denom_traces"}, "", runtime.AssumeColonVerbOpt(true))) diff --git a/proto/ibc/applications/transfer/v1/query.proto b/proto/ibc/applications/transfer/v1/query.proto index 2ed28049fd7..524ee16fa91 100644 --- a/proto/ibc/applications/transfer/v1/query.proto +++ b/proto/ibc/applications/transfer/v1/query.proto @@ -13,7 +13,7 @@ option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"; service Query { // DenomTrace queries a denomination trace information. rpc DenomTrace(QueryDenomTraceRequest) returns (QueryDenomTraceResponse) { - option (google.api.http).get = "/ibc/apps/transfer/v1/denom_traces/{hash}"; + option (google.api.http).get = "/ibc/apps/transfer/v1/denom_traces/{denom}"; } // DenomTraces queries all denomination traces. @@ -36,7 +36,7 @@ service Query { // method message QueryDenomTraceRequest { // hash (in hex format) of the denomination trace information. - string hash = 1; + string denom = 1; } // QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC From e03e19bb786ed4479113aa701319fe552c89cddb Mon Sep 17 00:00:00 2001 From: romelukaku Date: Fri, 29 Apr 2022 12:23:14 +0700 Subject: [PATCH 2/7] update q denom-traces cli --- modules/apps/transfer/client/cli/query.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/apps/transfer/client/cli/query.go b/modules/apps/transfer/client/cli/query.go index b81c8addfa3..c00f94e5b24 100644 --- a/modules/apps/transfer/client/cli/query.go +++ b/modules/apps/transfer/client/cli/query.go @@ -11,13 +11,13 @@ import ( "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" ) -// GetCmdQueryDenomTrace defines the command to query a a denomination trace from a given hash. +// GetCmdQueryDenomTrace defines the command to query a a denomination trace from a given denom. func GetCmdQueryDenomTrace() *cobra.Command { cmd := &cobra.Command{ - Use: "denom-trace [hash]", - Short: "Query the denom trace info from a given trace hash", - Long: "Query the denom trace info from a given trace hash", - Example: fmt.Sprintf("%s query ibc-transfer denom-trace [hash]", version.AppName), + Use: "denom-trace [denom]", + Short: "Query the denom trace info from a denom", + Long: "Query the denom trace info from a denom", + Example: fmt.Sprintf("%s query ibc-transfer denom-trace [denom]", version.AppName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) From 9c0c664c84b59894229c31576e139cfa8e1e2bd1 Mon Sep 17 00:00:00 2001 From: romelukaku Date: Fri, 29 Apr 2022 12:58:02 +0700 Subject: [PATCH 3/7] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f699f30ff3..b4623ae908f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking +* (transfer) [\#1312](https://github.com/cosmos/ibc-go/pull/1312) `DenomTrace` grpc now takes in the whole ibc denom instead of just the hash. * (transfer) [\#1250](https://github.com/cosmos/ibc-go/pull/1250) Deprecate `GetTransferAccount` since the `transfer` module account is never used. ### State Machine Breaking From bb0ca243eaf9ba17f058039807472d5efc9d123c Mon Sep 17 00:00:00 2001 From: khanh <50263489+catShaark@users.noreply.github.com> Date: Fri, 29 Apr 2022 20:20:26 +0700 Subject: [PATCH 4/7] Update modules/apps/transfer/keeper/grpc_query.go Co-authored-by: Carlos Rodriguez --- modules/apps/transfer/keeper/grpc_query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/transfer/keeper/grpc_query.go b/modules/apps/transfer/keeper/grpc_query.go index cfcc30d9e0c..050a4d51331 100644 --- a/modules/apps/transfer/keeper/grpc_query.go +++ b/modules/apps/transfer/keeper/grpc_query.go @@ -24,7 +24,7 @@ func (q Keeper) DenomTrace(c context.Context, req *types.QueryDenomTraceRequest) } if !strings.HasPrefix(req.Denom, "ibc/") { - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom with no ibc prefix %s", req.Denom)) + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom with no ibc prefix: %s", req.Denom)) } hash, err := types.ParseHexHash(req.Denom[4:]) From 951b0e1bfc24738d8f5da1ab72ccbdac2c0f5a3a Mon Sep 17 00:00:00 2001 From: khanh <50263489+catShaark@users.noreply.github.com> Date: Fri, 29 Apr 2022 20:20:35 +0700 Subject: [PATCH 5/7] Update modules/apps/transfer/keeper/grpc_query.go Co-authored-by: Carlos Rodriguez --- modules/apps/transfer/keeper/grpc_query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/transfer/keeper/grpc_query.go b/modules/apps/transfer/keeper/grpc_query.go index 050a4d51331..bda8740f941 100644 --- a/modules/apps/transfer/keeper/grpc_query.go +++ b/modules/apps/transfer/keeper/grpc_query.go @@ -29,7 +29,7 @@ func (q Keeper) DenomTrace(c context.Context, req *types.QueryDenomTraceRequest) hash, err := types.ParseHexHash(req.Denom[4:]) if err != nil { - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash %s, %s", req.Denom[4:], err)) + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash: %s, error: %s", req.Denom[4:], err)) } ctx := sdk.UnwrapSDKContext(c) From c81a378edd0b98f6b6323a5257c14a90b7143c58 Mon Sep 17 00:00:00 2001 From: romelukaku Date: Fri, 29 Apr 2022 20:26:45 +0700 Subject: [PATCH 6/7] update proto/ibc/applications/transfer/v1/query.proto --- proto/ibc/applications/transfer/v1/query.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/ibc/applications/transfer/v1/query.proto b/proto/ibc/applications/transfer/v1/query.proto index 524ee16fa91..1b16ba84337 100644 --- a/proto/ibc/applications/transfer/v1/query.proto +++ b/proto/ibc/applications/transfer/v1/query.proto @@ -35,7 +35,7 @@ service Query { // QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC // method message QueryDenomTraceRequest { - // hash (in hex format) of the denomination trace information. + // denom (full denom with ibc prefix) of the denomination trace information. string denom = 1; } From 49d08cbfb79be570af13dee4af455dba597f8bfc Mon Sep 17 00:00:00 2001 From: romelukaku Date: Wed, 4 May 2022 18:24:48 +0700 Subject: [PATCH 7/7] success case first --- .../apps/transfer/keeper/grpc_query_test.go | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/apps/transfer/keeper/grpc_query_test.go b/modules/apps/transfer/keeper/grpc_query_test.go index 5633dff6712..ca1cd5aaf8f 100644 --- a/modules/apps/transfer/keeper/grpc_query_test.go +++ b/modules/apps/transfer/keeper/grpc_query_test.go @@ -21,37 +21,37 @@ func (suite *KeeperTestSuite) TestQueryDenomTrace() { expPass bool }{ { - "invalid ibc denom", + "success", func() { + expTrace.Path = "transfer/channelToA/transfer/channelToB" + expTrace.BaseDenom = "uatom" + suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace) + req = &types.QueryDenomTraceRequest{ - Denom: "!@#!@#!", + Denom: expTrace.IBCDenom(), } }, - false, + true, }, { - "not found denom trace", + "invalid ibc denom", func() { - expTrace.Path = "transfer/channelToA/transfer/channelToB" - expTrace.BaseDenom = "uatom" req = &types.QueryDenomTraceRequest{ - Denom: expTrace.IBCDenom(), + Denom: "!@#!@#!", } }, false, }, { - "success", + "not found denom trace", func() { expTrace.Path = "transfer/channelToA/transfer/channelToB" expTrace.BaseDenom = "uatom" - suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), expTrace) - req = &types.QueryDenomTraceRequest{ Denom: expTrace.IBCDenom(), } }, - true, + false, }, }