Skip to content

Commit

Permalink
Review feedback and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Sep 12, 2024
1 parent 972661e commit 39549c9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
11 changes: 6 additions & 5 deletions simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import (
"encoding/binary"
"encoding/json"
"flag"
"github.com/cosmos/cosmos-sdk/simsx"
"io"
"math/rand"
"strings"
"sync"
"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"
Expand All @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions simsx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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.

4 changes: 3 additions & 1 deletion simsx/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions simsx/msg_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion simsx/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions x/gov/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 39549c9

Please sign in to comment.