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

refactor(types & client): fix tests #16064

Merged
merged 4 commits into from
May 8, 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 client/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
},
)

app.Commit(context.TODO(), &abci.RequestCommit{})
// app.Commit(context.TODO(), &abci.RequestCommit{}) // TODO see if this is needed
app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{
Height: app.LastBlockHeight() + 1,
Hash: app.LastCommitID().Hash,
Expand Down
10 changes: 6 additions & 4 deletions testutil/sims/app_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,18 @@ func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupCon
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
})

// commit genesis changes
if !startupConfig.AtGenesis {
app.Commit(context.TODO(), &abci.RequestCommit{})
app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{
// app.Commit(context.TODO(), &abci.RequestCommit{}) // TODO figure out if this is needed?
_, err := app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{
Height: app.LastBlockHeight() + 1,
NextValidatorsHash: valSet.Hash(),
})
if err != nil {
return nil, fmt.Errorf("failed to finalize block: %w", err)
}
}

return app, nil
Expand Down
7 changes: 1 addition & 6 deletions types/module/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestAssertNoForgottenModules(t *testing.T) {
module.CoreAppModuleBasicAdaptor("module3", mockAppModule3),
)
require.NotNil(t, mm)
require.Equal(t, 3, len(mm.Modules))
require.Equal(t, 2, len(mm.Modules))

require.Equal(t, []string{"module1", "module3"}, mm.OrderInitGenesis)
require.PanicsWithValue(t, "all modules must be defined when setting SetOrderInitGenesis, missing: [module3]", func() {
Expand All @@ -124,11 +124,6 @@ func TestAssertNoForgottenModules(t *testing.T) {
mm.SetOrderExportGenesis("module1")
})

require.Equal(t, []string{"module1", "module3"}, mm.OrderBeginBlockers)
require.PanicsWithValue(t, "all modules must be defined when setting SetOrderBeginBlockers, missing: [module2]", func() {
mm.SetOrderBeginBlockers("module1", "module3")
})

require.Equal(t, []string{"module1", "module3"}, mm.OrderEndBlockers)
require.PanicsWithValue(t, "all modules must be defined when setting SetOrderEndBlockers, missing: [module1]", func() {
mm.SetOrderEndBlockers("module3")
Expand Down
4 changes: 2 additions & 2 deletions types/msgservice/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ func TestValidateServiceAnnotations(t *testing.T) {
// Find an arbitrary query service that hasn't the service=true annotation.
sd, err := protoregistry.GlobalFiles.FindDescriptorByName("cosmos.bank.v1beta1.Query")
require.NoError(t, err)
err = validateMsgServiceAnnotations(nil, sd.(protoreflect.ServiceDescriptor))
err = validateMsgServiceAnnotations(sd.(protoreflect.ServiceDescriptor))
require.Error(t, err)

sd, err = protoregistry.GlobalFiles.FindDescriptorByName("cosmos.bank.v1beta1.Msg")
require.NoError(t, err)
err = validateMsgServiceAnnotations(nil, sd.(protoreflect.ServiceDescriptor))
err = validateMsgServiceAnnotations(sd.(protoreflect.ServiceDescriptor))
require.NoError(t, err)
}
4 changes: 2 additions & 2 deletions x/consensus/exported/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type (
// ConsensusParamSetter defines the interface fulfilled by BaseApp's
// ParamStore which allows setting its appVersion field.
ConsensusParamSetter interface {
Get(ctx context.Context) (*cmtproto.ConsensusParams, error)
Get(ctx context.Context) (cmtproto.ConsensusParams, error)
Has(ctx context.Context) (bool, error)
Set(ctx context.Context, cp *cmtproto.ConsensusParams) error
Set(ctx context.Context, cp cmtproto.ConsensusParams) error
}
)
4 changes: 4 additions & 0 deletions x/consensus/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import (
"cosmossdk.io/core/event"
storetypes "cosmossdk.io/core/store"
"cosmossdk.io/errors"

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmttypes "github.com/cometbft/cometbft/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/consensus/exported"
"github.com/cosmos/cosmos-sdk/x/consensus/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
Expand All @@ -27,6 +29,8 @@ type Keeper struct {
ParamsStore collections.Item[cmtproto.ConsensusParams]
}

var _ exported.ConsensusParamSetter = Keeper{}.ParamsStore

func NewKeeper(cdc codec.BinaryCodec, storeService storetypes.KVStoreService, authority string, em event.Service) Keeper {
sb := collections.NewSchemaBuilder(storeService)
return Keeper{
Expand Down