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

Fix tests #472

Merged
merged 3 commits into from
May 13, 2024
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 app/testing/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

// SimAppChainID hardcoded chainID for simulation
const (
SimAppChainID = "terra-app"
SimAppChainID = ""
)

var emptyWasmOpts []wasmkeeper.Option
Expand Down Expand Up @@ -98,7 +98,7 @@

func (EmptyAppOptions) Get(_ string) interface{} { return nil }

func SetupApp(t *testing.T, chainId string) *app.TerraApp {

Check warning on line 101 in app/testing/test_suite.go

View workflow job for this annotation

GitHub Actions / golangci-lint

var-naming: func parameter chainId should be chainID (revive)
t.Helper()

privVal := NewPV()
Expand All @@ -125,7 +125,7 @@
// that also act as delegators. For simplicity, each validator is bonded with a delegation
// of one consensus engine unit in the default token of the app from first genesis
// account. A Nop logger is set in app.
func SetupWithGenesisValSet(t *testing.T, chainId string, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *app.TerraApp {

Check warning on line 128 in app/testing/test_suite.go

View workflow job for this annotation

GitHub Actions / golangci-lint

var-naming: func parameter chainId should be chainID (revive)
t.Helper()

terraApp, genesisState := setup(chainId)
Expand Down Expand Up @@ -157,7 +157,7 @@
return terraApp
}

func setup(chainId string) (*app.TerraApp, app.GenesisState) {

Check warning on line 160 in app/testing/test_suite.go

View workflow job for this annotation

GitHub Actions / golangci-lint

var-naming: func parameter chainId should be chainID (revive)
db := dbm.NewMemDB()
encCdc := app.MakeEncodingConfig()
appOptions := make(simtestutil.AppOptionsMap, 0)
Expand Down
1 change: 0 additions & 1 deletion app/upgrades/v8/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {

// Set param key table for params module migration
for _, subspace := range keepers.ParamsKeeper.GetSubspaces() {
subspace := subspace
Expand All @@ -36,19 +35,19 @@
var keyTable paramstypes.KeyTable
switch subspace.Name() {
case authtypes.ModuleName:
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck

Check failure on line 38 in app/upgrades/v8/upgrades.go

View workflow job for this annotation

GitHub Actions / golangci-lint

directive `//nolint:staticcheck` is unused for linter "staticcheck" (nolintlint)
case banktypes.ModuleName:
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck

Check failure on line 40 in app/upgrades/v8/upgrades.go

View workflow job for this annotation

GitHub Actions / golangci-lint

directive `//nolint:staticcheck` is unused for linter "staticcheck" (nolintlint)
case stakingtypes.ModuleName:
keyTable = stakingtypes.ParamKeyTable() //nolint:staticcheck

Check failure on line 42 in app/upgrades/v8/upgrades.go

View workflow job for this annotation

GitHub Actions / golangci-lint

directive `//nolint:staticcheck` is unused for linter "staticcheck" (nolintlint)
case minttypes.ModuleName:
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck

Check failure on line 44 in app/upgrades/v8/upgrades.go

View workflow job for this annotation

GitHub Actions / golangci-lint

directive `//nolint:staticcheck` is unused for linter "staticcheck" (nolintlint)
case distrtypes.ModuleName:
keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck

Check failure on line 46 in app/upgrades/v8/upgrades.go

View workflow job for this annotation

GitHub Actions / golangci-lint

directive `//nolint:staticcheck` is unused for linter "staticcheck" (nolintlint)
case slashingtypes.ModuleName:
keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck

Check failure on line 48 in app/upgrades/v8/upgrades.go

View workflow job for this annotation

GitHub Actions / golangci-lint

directive `//nolint:staticcheck` is unused for linter "staticcheck" (nolintlint)
case govtypes.ModuleName:
keyTable = govv1.ParamKeyTable() //nolint:staticcheck

Check failure on line 50 in app/upgrades/v8/upgrades.go

View workflow job for this annotation

GitHub Actions / golangci-lint

directive `//nolint:staticcheck` is unused for linter "staticcheck" (nolintlint)
case wasmtypes.ModuleName:
keyTable = wasmtypes.ParamKeyTable()
case crisistypes.ModuleName:
Expand Down
45 changes: 17 additions & 28 deletions custom/bank/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/cosmos/cosmos-sdk/x/bank/types"
banksim "github.com/cosmos/cosmos-sdk/x/bank/simulation"
"github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/simulation"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"

simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
)
Expand Down Expand Up @@ -145,42 +145,31 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope
accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
// random number of inputs/outputs between [1, 3]
inputs := make([]types.Input, r.Intn(3)+1)
inputs := make([]types.Input, 1)
outputs := make([]types.Output, r.Intn(3)+1)

// collect signer privKeys
privs := make([]cryptotypes.PrivKey, len(inputs))

// use map to check if address already exists as input
usedAddrs := make(map[string]bool)
simAccount, _, coins, skip := randomSendFields(r, ctx, accs, bk, ak)

var totalSentCoins sdk.Coins
for i := range inputs {
// generate random input fields, ignore to address
simAccount, _, coins, skip := randomSendFields(r, ctx, accs, bk, ak)

// make sure account is fresh and not used in previous input
for usedAddrs[simAccount.Address.String()] {
simAccount, _, coins, skip = randomSendFields(r, ctx, accs, bk, ak)
}

if skip {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgMultiSend, "skip all transfers"), nil, nil
}
if skip {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgMultiSend, "skip all transfers"), nil, nil
}

// set input address in used address map
usedAddrs[simAccount.Address.String()] = true
// set input address in used address map
usedAddrs[simAccount.Address.String()] = true

// set signer privkey
privs[i] = simAccount.PrivKey
// set signer privkey
privs[0] = simAccount.PrivKey

// set next input and accumulate total sent coins
inputs[i] = types.NewInput(simAccount.Address, coins)
totalSentCoins = totalSentCoins.Add(coins...)
}
// set next input and accumulate total sent coins
inputs[0] = types.NewInput(simAccount.Address, coins)

// Check send_enabled status of each sent coin denom
if err := bk.IsSendEnabledCoins(ctx, totalSentCoins...); err != nil {
if err := bk.IsSendEnabledCoins(ctx, coins...); err != nil {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgMultiSend, err.Error()), nil, nil
}

Expand All @@ -190,12 +179,12 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope
var outCoins sdk.Coins
// split total sent coins into random subsets for output
if o == len(outputs)-1 {
outCoins = totalSentCoins
outCoins = coins
} else {
// take random subset of remaining coins for output
// and update remaining coins
outCoins = simtypes.RandSubsetCoins(r, totalSentCoins)
totalSentCoins = totalSentCoins.Sub(outCoins...)
outCoins = simtypes.RandSubsetCoins(r, coins)
coins = coins.Sub(outCoins...)
}

outputs[o] = types.NewOutput(outAddr.Address, outCoins)
Expand Down
2 changes: 1 addition & 1 deletion x/treasury/types/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

const (
Expand Down
Loading