Skip to content

Commit

Permalink
fix: correct path required proto testdata (backport cosmos#14991) (co…
Browse files Browse the repository at this point in the history
…smos#16083)

Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
2 people authored and roy-dydx committed Jul 11, 2023
1 parent e5bef05 commit e80006a
Show file tree
Hide file tree
Showing 35 changed files with 4,048 additions and 4,025 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (deps) [#16083](https://github.com/cosmos/cosmos-sdk/pull/16083) Bumps `proto-builder` image to 0.13.0.
* (client) [#16075](https://github.com/cosmos/cosmos-sdk/pull/16075) Partly revert [#15953](https://github.com/cosmos/cosmos-sdk/issues/15953) and `factory.Prepare` now does nothing in offline mode.
* (server) [#15984](https://github.com/cosmos/cosmos-sdk/pull/15984) Use `cosmossdk.io/log` package for logging instead of CometBFT logger. NOTE: v0.45 and v0.46 were not using CometBFT logger either. This keeps the same underlying logger (zerolog) as in v0.45.x+ and v0.46.x+ but now properly supporting filtered logging.
* (gov) [#15979](https://github.com/cosmos/cosmos-sdk/pull/15979) Improve gov error message when failing to convert v1 proposal to v1beta1.
Expand All @@ -47,6 +48,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (x/group) [#16017](https://github.com/cosmos/cosmos-sdk/pull/16017) Correctly apply account number in group v2 migration.

### API Breaking Changes

* (testutil) [#14991](https://github.com/cosmos/cosmos-sdk/pull/14991) The `testutil/testdata_pulsar` package has moved to `testutil/testdata/testpb`. Chains will not notice this breaking change as this package contains testing utilities only used by the SDK internally.

## [v0.47.2](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.2) - 2023-04-27

### Improvements
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ devdoc-update:
### Protobuf ###
###############################################################################

protoVer=0.11.6
protoVer=0.13.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

Expand Down
6 changes: 3 additions & 3 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestABCI_GRPCQuery(t *testing.T) {

resQuery := suite.baseApp.Query(abci.RequestQuery{
Data: reqBz,
Path: "/testdata.Query/SayHello",
Path: "/testpb.Query/SayHello",
})
require.Equal(t, sdkerrors.ErrInvalidHeight.ABCICode(), resQuery.Code, resQuery)
require.Contains(t, resQuery.Log, "TestABCI_GRPCQuery is not ready; please wait for first block")
Expand All @@ -216,7 +216,7 @@ func TestABCI_GRPCQuery(t *testing.T) {

reqQuery := abci.RequestQuery{
Data: reqBz,
Path: "/testdata.Query/SayHello",
Path: "/testpb.Query/SayHello",
}

resQuery = suite.baseApp.Query(reqQuery)
Expand Down Expand Up @@ -1517,7 +1517,7 @@ func TestABCI_PrepareProposal_ReachedMaxBytes(t *testing.T) {
Height: 1,
}
resPrepareProposal := suite.baseApp.PrepareProposal(reqPrepareProposal)
require.Equal(t, 10, len(resPrepareProposal.Txs))
require.Equal(t, 11, len(resPrepareProposal.Txs))
}

func TestABCI_PrepareProposal_BadEncoding(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
require.Equal(t, []byte("ok"), okValue)
}
// check block gas is always consumed
baseGas := uint64(51822) // baseGas is the gas consumed before tx msg
baseGas := uint64(51732) // baseGas is the gas consumed before tx msg
expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas)
if expGasConsumed > txtypes.MaxGasWanted {
// capped by gasLimit
Expand Down
2 changes: 1 addition & 1 deletion baseapp/grpcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar"
testdata_pulsar "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down
77 changes: 38 additions & 39 deletions baseapp/testutil/messages.pb.go

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

1 change: 0 additions & 1 deletion baseapp/testutil/messages.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
syntax = "proto3";
package testdata;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
Expand Down
16 changes: 8 additions & 8 deletions client/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestContext_PrintProto(t *testing.T) {
err = ctx.PrintProto(hasAnimal)
require.NoError(t, err)
require.Equal(t,
`{"animal":{"@type":"/testdata.Dog","size":"big","name":"Spot"},"x":"10"}
`{"animal":{"@type":"/testpb.Dog","size":"big","name":"Spot"},"x":"10"}
`, buf.String())

// yaml
Expand All @@ -61,7 +61,7 @@ func TestContext_PrintProto(t *testing.T) {
require.NoError(t, err)
require.Equal(t,
`animal:
'@type': /testdata.Dog
'@type': /testpb.Dog
name: Spot
size: big
x: "10"
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestContext_PrintObjectLegacy(t *testing.T) {
err = ctx.PrintObjectLegacy(hasAnimal)
require.NoError(t, err)
require.Equal(t,
`{"type":"testdata/HasAnimal","value":{"animal":{"type":"testdata/Dog","value":{"size":"big","name":"Spot"}},"x":"10"}}
`{"type":"testpb/HasAnimal","value":{"animal":{"type":"testpb/Dog","value":{"size":"big","name":"Spot"}},"x":"10"}}
`, buf.String())

// yaml
Expand All @@ -103,10 +103,10 @@ func TestContext_PrintObjectLegacy(t *testing.T) {
err = ctx.PrintObjectLegacy(hasAnimal)
require.NoError(t, err)
require.Equal(t,
`type: testdata/HasAnimal
`type: testpb/HasAnimal
value:
animal:
type: testdata/Dog
type: testpb/Dog
value:
name: Spot
size: big
Expand All @@ -116,7 +116,7 @@ value:

func TestContext_PrintRaw(t *testing.T) {
ctx := client.Context{}
hasAnimal := json.RawMessage(`{"animal":{"@type":"/testdata.Dog","size":"big","name":"Spot"},"x":"10"}`)
hasAnimal := json.RawMessage(`{"animal":{"@type":"/testpb.Dog","size":"big","name":"Spot"},"x":"10"}`)

// json
buf := &bytes.Buffer{}
Expand All @@ -125,7 +125,7 @@ func TestContext_PrintRaw(t *testing.T) {
err := ctx.PrintRaw(hasAnimal)
require.NoError(t, err)
require.Equal(t,
`{"animal":{"@type":"/testdata.Dog","size":"big","name":"Spot"},"x":"10"}
`{"animal":{"@type":"/testpb.Dog","size":"big","name":"Spot"},"x":"10"}
`, buf.String())

// yaml
Expand All @@ -136,7 +136,7 @@ func TestContext_PrintRaw(t *testing.T) {
require.NoError(t, err)
require.Equal(t,
`animal:
'@type': /testdata.Dog
'@type': /testpb.Dog
name: Spot
size: big
x: "10"
Expand Down
6 changes: 3 additions & 3 deletions codec/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestRegister(t *testing.T) {
// Duplicate registration with different concrete type on same typeURL.
require.PanicsWithError(
t,
"concrete type *testdata.Dog has already been registered under typeURL /testdata.Dog, cannot register *types_test.FakeDog under same typeURL. "+
"concrete type *testdata.Dog has already been registered under typeURL /testpb.Dog, cannot register *types_test.FakeDog under same typeURL. "+
"This usually means that there are conflicting modules registering different concrete types for a same interface implementation",
func() {
registry.RegisterImplementations((*testdata.Animal)(nil), &FakeDog{})
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestAny_ProtoJSON(t *testing.T) {
jm := &jsonpb.Marshaler{}
json, err := jm.MarshalToString(any)
require.NoError(t, err)
require.Equal(t, "{\"@type\":\"/testdata.Dog\",\"name\":\"Spot\"}", json)
require.Equal(t, "{\"@type\":\"/testpb.Dog\",\"name\":\"Spot\"}", json)

registry := testdata.NewTestInterfaceRegistry()
jum := &jsonpb.Unmarshaler{}
Expand All @@ -170,7 +170,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\":\"/testdata.Dog\",\"name\":\"Spot\"}}", json)
require.Equal(t, "{\"animal\":{\"@type\":\"/testpb.Dog\",\"name\":\"Spot\"}}", json)

require.NoError(t, err)
var ha2 testdata.HasAnimal
Expand Down
6 changes: 3 additions & 3 deletions codec/unknownproto/unknown_fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func TestRejectUnknownFieldsNested(t *testing.T) {
name: "unknown field types.Any in G",
in: &testdata.TestVersion3{
G: &types.Any{
TypeUrl: "/testdata.TestVersion1",
TypeUrl: "/testpb.TestVersion1",
Value: mustMarshal(&testdata.TestVersion2{
Sum: &testdata.TestVersion2_F{
F: &testdata.TestVersion2{
Expand All @@ -410,7 +410,7 @@ func TestRejectUnknownFieldsNested(t *testing.T) {
in: &testdata.TestVersionFD1WithExtraAny{
G: &testdata.AnyWithExtra{
Any: &types.Any{
TypeUrl: "/testdata.TestVersion1",
TypeUrl: "/testpb.TestVersion1",
Value: mustMarshal(&testdata.TestVersion2{
Sum: &testdata.TestVersion2_F{
F: &testdata.TestVersion2{
Expand All @@ -434,7 +434,7 @@ func TestRejectUnknownFieldsNested(t *testing.T) {
name: "mismatched types.Any in G",
in: &testdata.TestVersion1{
G: &types.Any{
TypeUrl: "/testdata.TestVersion4LoneNesting",
TypeUrl: "/testpb.TestVersion4LoneNesting",
Value: mustMarshal(&testdata.TestVersion3LoneNesting_Inner1{
Inner: &testdata.TestVersion3LoneNesting_Inner1_InnerInner{
Id: "ID",
Expand Down
6 changes: 3 additions & 3 deletions codec/yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestMarshalYAML(t *testing.T) {
bz, err := codec.MarshalYAML(protoCdc, hasAnimal)
require.NoError(t, err)
require.Equal(t, `animal:
'@type': /testdata.Dog
'@type': /testpb.Dog
name: Spot
size: small
x: "0"
Expand All @@ -38,10 +38,10 @@ x: "0"
aminoCdc := codec.NewAminoCodec(&codec.LegacyAmino{testdata.NewTestAmino()})
bz, err = codec.MarshalYAML(aminoCdc, hasAnimal)
require.NoError(t, err)
require.Equal(t, `type: testdata/HasAnimal
require.Equal(t, `type: testpb/HasAnimal
value:
animal:
type: testdata/Dog
type: testpb/Dog
value:
name: Spot
size: small
Expand Down
2 changes: 1 addition & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/store/streaming"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar"
testdata_pulsar "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
Expand Down
2 changes: 1 addition & 1 deletion simapp/app_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/store/streaming"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar"
testdata_pulsar "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
Expand Down
6 changes: 6 additions & 0 deletions testutil/testdata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# testdata

The testdata directory contains gogo and pulsar generated code:

* `testdata/*.go` : gogo
* `testdata/testpb/*.go`: pulsar
Loading

0 comments on commit e80006a

Please sign in to comment.