Skip to content

Commit

Permalink
Fix testdata proto-gen (cosmos#6568)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc authored Jul 1, 2020
1 parent 0f0723d commit 99ea4b7
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 64 deletions.
2 changes: 1 addition & 1 deletion baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ func TestGRPCQuery(t *testing.T) {

reqQuery := abci.RequestQuery{
Data: reqBz,
Path: "/cosmos_sdk.codec.v1.TestService/SayHello",
Path: "/testdata.TestService/SayHello",
}

resQuery := app.Query(reqQuery)
Expand Down
4 changes: 2 additions & 2 deletions client/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestContext_PrintOutput(t *testing.T) {
err = ctx.PrintOutput(hasAnimal)
require.NoError(t, err)
require.Equal(t,
`{"animal":{"@type":"/cosmos_sdk.codec.v1.Dog","size":"big","name":"Spot"},"x":"10"}
`{"animal":{"@type":"/testdata.Dog","size":"big","name":"Spot"},"x":"10"}
`, string(buf.Bytes()))

// yaml
Expand All @@ -120,7 +120,7 @@ func TestContext_PrintOutput(t *testing.T) {
require.NoError(t, err)
require.Equal(t,
`animal:
'@type': /cosmos_sdk.codec.v1.Dog
'@type': /testdata.Dog
name: Spot
size: big
x: "10"
Expand Down
115 changes: 57 additions & 58 deletions codec/testdata/proto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion codec/testdata/proto.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package cosmos_sdk.codec.v1;
package testdata;

import "google/protobuf/any.proto";

Expand Down
4 changes: 2 additions & 2 deletions codec/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestAny_ProtoJSON(t *testing.T) {
jm := &jsonpb.Marshaler{}
json, err := jm.MarshalToString(any)
require.NoError(t, err)
require.Equal(t, "{\"@type\":\"/cosmos_sdk.codec.v1.Dog\",\"name\":\"Spot\"}", json)
require.Equal(t, "{\"@type\":\"/testdata.Dog\",\"name\":\"Spot\"}", json)

registry := testdata.NewTestInterfaceRegistry()
jum := &jsonpb.Unmarshaler{}
Expand All @@ -143,7 +143,7 @@ func TestAny_ProtoJSON(t *testing.T) {
require.NoError(t, err)
json, err = jm.MarshalToString(ha)
require.NoError(t, err)
require.Equal(t, "{\"animal\":{\"@type\":\"/cosmos_sdk.codec.v1.Dog\",\"name\":\"Spot\"}}", json)
require.Equal(t, "{\"animal\":{\"@type\":\"/testdata.Dog\",\"name\":\"Spot\"}}", json)

require.NoError(t, err)
var ha2 testdata.HasAnimal
Expand Down
7 changes: 7 additions & 0 deletions scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,12 @@ Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
$(find "${dir}" -maxdepth 1 -name '*.proto')
done

# generate codec/testdata proto code
protoc -I "proto" -I "third_party/proto" -I "codec/testdata" --gocosmos_out=plugins=interfacetype+grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. ./codec/testdata/proto.proto

# move proto files to the right places
cp -r github.com/cosmos/cosmos-sdk/* ./
rm -rf github.com


0 comments on commit 99ea4b7

Please sign in to comment.