Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct path required proto testdata #14991

Merged
merged 7 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ run:
timeout: 10m
sort-results: true
allow-parallel-runners: true
exclude-dir: testutil/testdata_pulsar
exclude-dir: testutil/testdata
concurrency: 4

linters:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes

* (testutil) [#14991](https://github.com/cosmos/cosmos-sdk/pull/14991) The `testutil/testdata_pulsar` package has moved to `testutil/testdata/testpb`.
* (simapp) [#14977](https://github.com/cosmos/cosmos-sdk/pull/14977) Move simulation helpers functions (`AppStateFn` and `AppStateRandomizedFn`) to `testutil/sims`. These takes an extra genesisState argument which is the default state of the app.
* (x/gov) [#14720](https://github.com/cosmos/cosmos-sdk/pull/14720) Add an expedited field in the gov v1 proposal and `MsgNewMsgProposal`.
* [#14847](https://github.com/cosmos/cosmos-sdk/pull/14847) App and ModuleManager methods `InitGenesis`, `ExportGenesis`, `BeginBlock` and `EndBlock` now also return an error.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ format:
### Protobuf ###
###############################################################################

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

Expand Down
7 changes: 5 additions & 2 deletions api/cosmos/orm/v1/orm.pulsar.go

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

6 changes: 3 additions & 3 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,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 @@ -199,7 +199,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 @@ -1448,7 +1448,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
4 changes: 2 additions & 2 deletions baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ 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
expGasConsumed = txtypes.MaxGasWanted
}
require.Equal(t, expGasConsumed, ctx.BlockGasMeter().GasConsumed())
require.Equal(t, int(expGasConsumed), int(ctx.BlockGasMeter().GasConsumed()))
// tx fee is always deducted
require.Equal(t, int64(0), bankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount.Int64())
// sender's sequence is always increased
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
Loading