From 39549c9b5242162aa9cebfa27912c17a299e28fc Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Thu, 12 Sep 2024 14:06:30 +0200 Subject: [PATCH] Review feedback and linting --- simapp/sim_test.go | 11 ++++++----- simsx/README.md | 4 +--- simsx/common_test.go | 4 +++- simsx/msg_factory_test.go | 3 +-- simsx/runner.go | 2 +- x/gov/module.go | 1 + 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/simapp/sim_test.go b/simapp/sim_test.go index d71081922329..b88a97601de5 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -6,7 +6,6 @@ import ( "encoding/binary" "encoding/json" "flag" - "github.com/cosmos/cosmos-sdk/simsx" "io" "math/rand" "strings" @@ -14,6 +13,11 @@ import ( "testing" "time" + abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" + cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + corestore "cosmossdk.io/core/store" "cosmossdk.io/log" "cosmossdk.io/store" @@ -22,13 +26,10 @@ import ( "cosmossdk.io/x/feegrant" slashingtypes "cosmossdk.io/x/slashing/types" stakingtypes "cosmossdk.io/x/staking/types" - abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" - cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/baseapp" servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/simsx" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" diff --git a/simsx/README.md b/simsx/README.md index 676db329db18..fe1cc2058113 100644 --- a/simsx/README.md +++ b/simsx/README.md @@ -17,7 +17,6 @@ func MsgSendFactory() simsx.SimMsgFactoryFn[*types.MsgSend] { } ``` - #### * [Sims registry](https://github.com/cosmos/cosmos-sdk/blob/main/simsx/registry.go) A new helper to register message factories with a default weight value. They can be overwritten by a parameters file as before. The registry is passed to the AppModule type. For example: @@ -27,6 +26,7 @@ func (am AppModule) WeightedOperationsX(weights simsx.WeightSource, reg simsx.Re reg.Add(weights.Get("msg_multisend", 10), simulation.MsgMultiSendFactory()) } ``` + #### * [Reporter](https://github.com/cosmos/cosmos-sdk/blob/main/simsx/reporter.go) The reporter is a flow control structure that can be used in message factories to skip execution at any point. The idea is similar to the testing.T Skip in Go stdlib. Internally, it converts skip, success and failure events to legacy sim messages. The reporter also provides some capability to print an execution summary. @@ -36,9 +36,7 @@ Message factories may want to abort early via if reporter.IsSkipped() { return nil, nil } - ``` #### * [Test data environment](https://github.com/cosmos/cosmos-sdk/blob/main/simsx/environment.go) The test data environment provides simple access to accounts and other test data used in most message factories. It also encapsulates some app internals like bank keeper or address codec. - diff --git a/simsx/common_test.go b/simsx/common_test.go index 816be7d860e5..43fcd7d41860 100644 --- a/simsx/common_test.go +++ b/simsx/common_test.go @@ -4,8 +4,11 @@ import ( "context" "math/rand" + "github.com/cosmos/gogoproto/proto" + coretransaction "cosmossdk.io/core/transaction" "cosmossdk.io/x/tx/signing" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/address" @@ -16,7 +19,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/auth/tx" - "github.com/cosmos/gogoproto/proto" ) // SimAccountFixture testing only diff --git a/simsx/msg_factory_test.go b/simsx/msg_factory_test.go index 2d7c8e3c2da3..d5cadb222b69 100644 --- a/simsx/msg_factory_test.go +++ b/simsx/msg_factory_test.go @@ -5,12 +5,11 @@ import ( "errors" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" ) func TestMsgFactories(t *testing.T) { diff --git a/simsx/runner.go b/simsx/runner.go index a626c3f0edc4..a94aeb265b7d 100644 --- a/simsx/runner.go +++ b/simsx/runner.go @@ -242,7 +242,7 @@ func prepareWeightedOps( pReg := make(UniqueTypeRegistry) wProps := make([]simtypes.WeightedProposalMsg, 0, len(sm.Modules)) - wContent := make([]simtypes.WeightedProposalContent, 0) + wContent := make([]simtypes.WeightedProposalContent, 0) //nolint:staticcheck // required for legacy type // add gov proposals types for _, m := range sm.Modules { diff --git a/x/gov/module.go b/x/gov/module.go index 41ed6a2b326b..8fc5f3061aab 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" "google.golang.org/grpc"