Skip to content

Commit

Permalink
refactor!: make simapp.MakeTestEncodingConfig private (#12747)
Browse files Browse the repository at this point in the history
* feat: make `simapp.MakeTestEncodingConfig` private

* fix legacy build

* update changelog and upgrading.md

* updates docs
  • Loading branch information
julienrbrt authored Jul 27, 2022
1 parent f7db013 commit f770f8c
Show file tree
Hide file tree
Showing 28 changed files with 149 additions and 136 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes

* (simapp) [#12747](https://github.com/cosmos/cosmos-sdk/pull/12747) Remove `simapp.MakeTestEncodingConfig`. Please use `moduletestutil.MakeTestEncodingConfig` (`types/module/testutil`) in tests instead.
* (x/bank) [#12648](https://github.com/cosmos/cosmos-sdk/pull/12648) `NewSendAuthorization` takes a new argument of an optional list of addresses allowed to receive bank assests via authz MsgSend grant. You can pass `nil` for the same behavior as before, i.e. any recipient is allowed.
* (x/bank) [\#12593](https://github.com/cosmos/cosmos-sdk/pull/12593) Add `SpendableCoin` method to `BaseViewKeeper`
* (x/slashing) [#12581](https://github.com/cosmos/cosmos-sdk/pull/12581) Remove `x/slashing` legacy querier.
Expand Down
10 changes: 8 additions & 2 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ This means that modules are injected directly into SimApp thanks to a [configura
The old behavior is preserved and still can be used, without the dependency injection framework, as shows [`app_legacy.go`](https://github.com/cosmos/cosmos-sdk/blob/main/simapp/app_legacy.go).

The constructor, `NewSimApp` has been simplified:
- `NewSimApp` does not take encoding parameters (`encodingConfig`) as input, instead the encoding parameters are injected (when using app wiring), or directly created in the constructor. Instead, we can instantiate `SimApp` for getting the encoding configuration.
- `NewSimApp` now uses `AppOptions` for getting the home path (`homePath`) and the invariant checks period (`invCheckPeriod`). These were unnecessary given as arguments as they were already present in the `AppOptions`.

* `NewSimApp` does not take encoding parameters (`encodingConfig`) as input, instead the encoding parameters are injected (when using app wiring), or directly created in the constructor. Instead, we can instantiate `SimApp` for getting the encoding configuration.
* `NewSimApp` now uses `AppOptions` for getting the home path (`homePath`) and the invariant checks period (`invCheckPeriod`). These were unnecessary given as arguments as they were already present in the `AppOptions`.

### Encoding

`simapp.MakeTestEncodingConfig()` was deprecated and has been removed. Instead you can use the `TestEncodingConfig` from the `types/module/testutil` package.
This means you can replace your usage of `simapp.MakeTestEncodingConfig` in tests to `moduletestutil.MakeTestEncodingConfig`, which takes a series of relevant `AppModuleBasic` as input (the module being tested and any potential dependencies).

## [v0.46.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0)

Expand Down
7 changes: 3 additions & 4 deletions docs/run-node/txs.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,11 @@ import (
)

func sendTx() error {
// Choose your codec: Amino or Protobuf. Here, we use Protobuf, given by the
// following function.
encCfg := simapp.MakeTestEncodingConfig()
// Choose your codec: Amino or Protobuf. Here, we use Protobuf, given by the following function.
app := simapp.NewSimApp(...)

// Create a new TxBuilder.
txBuilder := encCfg.TxConfig.NewTxBuilder()
txBuilder := app.TxConfig().NewTxBuilder()

// --snip--
}
Expand Down
13 changes: 12 additions & 1 deletion simapp/app_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/store/streaming"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar"
Expand Down Expand Up @@ -211,7 +213,7 @@ func NewSimApp(
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *SimApp {
encodingConfig := MakeTestEncodingConfig()
encodingConfig := makeEncodingConfig()

appCodec := encodingConfig.Codec
legacyAmino := encodingConfig.Amino
Expand Down Expand Up @@ -684,3 +686,12 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

return paramsKeeper
}

func makeEncodingConfig() simappparams.EncodingConfig {
encodingConfig := simappparams.MakeTestEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}
19 changes: 0 additions & 19 deletions simapp/encoding.go

This file was deleted.

5 changes: 3 additions & 2 deletions simapp/simd/cmd/genaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/simapp"
simcmd "github.com/cosmos/cosmos-sdk/simapp/simd/cmd"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/types/module"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
)
Expand Down Expand Up @@ -73,7 +74,7 @@ func TestAddGenesisAccountCmd(t *testing.T) {
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
require.NoError(t, err)

appCodec := simapp.MakeTestEncodingConfig().Codec
appCodec := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}).Codec
err = genutiltest.ExecInitCmd(testMbm, home, appCodec)
require.NoError(t, err)

Expand Down
5 changes: 4 additions & 1 deletion simapp/simd/cmd/testnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/simapp"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/staking"
)

func Test_TestnetCmd(t *testing.T) {
home := t.TempDir()
encodingConfig := simapp.MakeTestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModuleBasic{}, auth.AppModuleBasic{})
logger := log.NewNopLogger()
cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
require.NoError(t, err)
Expand Down
17 changes: 9 additions & 8 deletions x/bank/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -96,8 +97,8 @@ func TestSendNotEnoughBalance(t *testing.T) {

sendMsg := types.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)})
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
txGen := simapp.MakeTestEncodingConfig().TxConfig
_, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1)
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
_, _, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1)
require.Error(t, err)

simapp.CheckBalance(t, app, addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 67)})
Expand Down Expand Up @@ -171,8 +172,8 @@ func TestMsgMultiSendWithAccounts(t *testing.T) {

for _, tc := range testCases {
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
txGen := simapp.MakeTestEncodingConfig().TxConfig
_, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
_, _, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
if tc.expPass {
require.NoError(t, err)
} else {
Expand Down Expand Up @@ -221,8 +222,8 @@ func TestMsgMultiSendMultipleOut(t *testing.T) {

for _, tc := range testCases {
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
txGen := simapp.MakeTestEncodingConfig().TxConfig
_, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
_, _, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
require.NoError(t, err)

for _, eb := range tc.expectedBalances {
Expand Down Expand Up @@ -273,8 +274,8 @@ func TestMsgMultiSendDependent(t *testing.T) {

for _, tc := range testCases {
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
txGen := simapp.MakeTestEncodingConfig().TxConfig
_, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
_, _, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
require.NoError(t, err)

for _, eb := range tc.expectedBalances {
Expand Down
5 changes: 4 additions & 1 deletion x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/x/auth"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/bank/exported"
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
Expand Down Expand Up @@ -83,7 +86,7 @@ type IntegrationTestSuite struct {
func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[string]bool) (authkeeper.AccountKeeper, keeper.BaseKeeper) {
app := suite.app
maccPerms := simapp.GetMaccPerms()
appCodec := simapp.MakeTestEncodingConfig().Codec
appCodec := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}, bank.AppModuleBasic{}).Codec

maccPerms[holder] = nil
maccPerms[authtypes.Burner] = []string{authtypes.Burner}
Expand Down
4 changes: 2 additions & 2 deletions x/bank/migrations/v2/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
v2bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

func TestMigrateJSON(t *testing.T) {
encodingConfig := simapp.MakeTestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()
clientCtx := client.Context{}.
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
Expand Down
6 changes: 3 additions & 3 deletions x/bank/migrations/v2/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import (
"cosmossdk.io/math"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/store/prefix"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
v1bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v1"
v2bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

func TestSupplyMigration(t *testing.T) {
encCfg := simapp.MakeTestEncodingConfig()
encCfg := moduletestutil.MakeTestEncodingConfig()
bankKey := sdk.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
store := ctx.KVStore(bankKey)
Expand Down Expand Up @@ -68,7 +68,7 @@ func TestSupplyMigration(t *testing.T) {
}

func TestBalanceKeysMigration(t *testing.T) {
encCfg := simapp.MakeTestEncodingConfig()
encCfg := moduletestutil.MakeTestEncodingConfig()
bankKey := sdk.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
store := ctx.KVStore(bankKey)
Expand Down
6 changes: 3 additions & 3 deletions x/bank/migrations/v3/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import (
"cosmossdk.io/math"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/store/prefix"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
v2 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2"
v3 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v3"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

func TestMigrateStore(t *testing.T) {
encCfg := simapp.MakeTestEncodingConfig()
encCfg := moduletestutil.MakeTestEncodingConfig()
bankKey := sdk.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
store := ctx.KVStore(bankKey)
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestMigrateStore(t *testing.T) {
}

func TestMigrateDenomMetaData(t *testing.T) {
encCfg := simapp.MakeTestEncodingConfig()
encCfg := moduletestutil.MakeTestEncodingConfig()
bankKey := sdk.NewKVStoreKey("bank")
ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test"))
store := ctx.KVStore(bankKey)
Expand Down
14 changes: 9 additions & 5 deletions x/genutil/gentx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (

"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/simapp"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
Expand All @@ -40,17 +40,21 @@ type GenTxTestSuite struct {

ctx sdk.Context
app *simapp.SimApp
encodingConfig simappparams.EncodingConfig

msg1, msg2 *stakingtypes.MsgCreateValidator
encodingConfig moduletestutil.TestEncodingConfig
msg1, msg2 *stakingtypes.MsgCreateValidator
}

func (suite *GenTxTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{})
suite.app = app
suite.encodingConfig = simapp.MakeTestEncodingConfig()
suite.encodingConfig = moduletestutil.TestEncodingConfig{
InterfaceRegistry: app.InterfaceRegistry(),
Codec: app.AppCodec(),
TxConfig: app.TxConfig(),
Amino: app.LegacyAmino(),
}

var err error
amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 50)
Expand Down
20 changes: 11 additions & 9 deletions x/genutil/types/genesis_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand Down Expand Up @@ -46,14 +48,14 @@ func TestValidateGenesisMultipleMessages(t *testing.T) {
sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, math.OneInt())
require.NoError(t, err)

txGen := simapp.MakeTestEncodingConfig().TxConfig
txBuilder := txGen.NewTxBuilder()
txConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModuleBasic{}, genutil.AppModuleBasic{}).TxConfig
txBuilder := txConfig.NewTxBuilder()
require.NoError(t, txBuilder.SetMsgs(msg1, msg2))

tx := txBuilder.GetTx()
genesisState := types.NewGenesisStateFromTx(txGen.TxJSONEncoder(), []sdk.Tx{tx})
genesisState := types.NewGenesisStateFromTx(txConfig.TxJSONEncoder(), []sdk.Tx{tx})

err = types.ValidateGenesis(genesisState, simapp.MakeTestEncodingConfig().TxConfig.TxJSONDecoder())
err = types.ValidateGenesis(genesisState, txConfig.TxJSONDecoder())
require.Error(t, err)
}

Expand All @@ -62,15 +64,15 @@ func TestValidateGenesisBadMessage(t *testing.T) {

msg1 := stakingtypes.NewMsgEditValidator(sdk.ValAddress(pk1.Address()), desc, nil, nil)

txGen := simapp.MakeTestEncodingConfig().TxConfig
txBuilder := txGen.NewTxBuilder()
txConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModuleBasic{}, genutil.AppModuleBasic{}).TxConfig
txBuilder := txConfig.NewTxBuilder()
err := txBuilder.SetMsgs(msg1)
require.NoError(t, err)

tx := txBuilder.GetTx()
genesisState := types.NewGenesisStateFromTx(txGen.TxJSONEncoder(), []sdk.Tx{tx})
genesisState := types.NewGenesisStateFromTx(txConfig.TxJSONEncoder(), []sdk.Tx{tx})

err = types.ValidateGenesis(genesisState, simapp.MakeTestEncodingConfig().TxConfig.TxJSONDecoder())
err = types.ValidateGenesis(genesisState, txConfig.TxJSONDecoder())
require.Error(t, err)
}

Expand Down
5 changes: 3 additions & 2 deletions x/gov/client/utils/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/gov/client/utils"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)
Expand Down Expand Up @@ -75,7 +76,7 @@ func (mock TxSearchMock) Block(ctx context.Context, height *int64) (*coretypes.R
}

func TestGetPaginatedVotes(t *testing.T) {
encCfg := simapp.MakeTestEncodingConfig()
encCfg := moduletestutil.MakeTestEncodingConfig(gov.AppModuleBasic{})

type testCase struct {
description string
Expand Down
Loading

0 comments on commit f770f8c

Please sign in to comment.