Skip to content

Commit

Permalink
fix: correct path required proto testdata (#14991)
Browse files Browse the repository at this point in the history
(cherry picked from commit a90569c)

# Conflicts:
#	.golangci.yml
#	CHANGELOG.md
#	simapp/app.go
#	simapp/app_v2.go
#	testutil/assert_helpers.go
#	testutil/testdata/testpb/pulsar_query.go
#	testutil/testdata/testpb/query_grpc.pb.go
#	testutil/testdata/testpb/tx_grpc.pb.go
#	x/auth/ante/testutil_test.go
  • Loading branch information
julienrbrt authored and mergify[bot] committed May 10, 2023
1 parent 850bd71 commit c2219b3
Show file tree
Hide file tree
Showing 38 changed files with 3,454 additions and 3,357 deletions.
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
run:
<<<<<<< HEAD
tests: false
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
=======
tests: true
timeout: 10m
sort-results: true
allow-parallel-runners: true
exclude-dir: testutil/testdata
concurrency: 4
>>>>>>> a90569c7e (fix: correct path required proto testdata (#14991))

linters:
disable-all: true
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,14 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes

<<<<<<< HEAD
* Migrate to CometBFT. Follow the migration instructions in the [upgrade guide](./UPGRADING.md#migration-to-cometbft-part-1).
=======
* (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.
>>>>>>> a90569c7e (fix: correct path required proto testdata (#14991))
* (simulation) [#14728](https://github.com/cosmos/cosmos-sdk/pull/14728) Rename the `ParamChanges` field to `LegacyParamChange` and `Contents` to `LegacyProposalContents` in `simulation.SimulationState`. Additionally it adds a `ProposalMsgs` field to `simulation.SimulationState`.
* (x/gov) [#14782](https://github.com/cosmos/cosmos-sdk/pull/14782) Move the `metadata` argument in `govv1.NewProposal` alongside `title` and `summary`.
* (x/upgrade) [#14216](https://github.com/cosmos/cosmos-sdk/pull/14216) Change upgrade keeper receiver to upgrade keeper pointers.
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.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 @@ -190,7 +190,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 @@ -201,7 +201,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 @@ -1453,7 +1453,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 @@ -166,13 +166,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
Loading

0 comments on commit c2219b3

Please sign in to comment.