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

bump wasm to v0.45.x, cosmos-sdk to v0.47.7, ibc-go to v7.3.0, cometb… #1

Merged
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
4 changes: 2 additions & 2 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
ibcante "github.com/cosmos/ibc-go/v6/modules/core/ante"
"github.com/cosmos/ibc-go/v6/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
"github.com/cosmos/ibc-go/v7/modules/core/keeper"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"

Check failure on line 11 in app/ante.go

View workflow job for this annotation

GitHub Actions / test

missing go.sum entry for module providing package github.com/CosmWasm/wasmd/x/wasm/keeper (imported by github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app); to add:

Check failure on line 11 in app/ante.go

View workflow job for this annotation

GitHub Actions / build

missing go.sum entry for module providing package github.com/CosmWasm/wasmd/x/wasm/keeper (imported by github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app); to add:

Check failure on line 11 in app/ante.go

View workflow job for this annotation

GitHub Actions / Analyze

missing go.sum entry for module providing package github.com/CosmWasm/wasmd/x/wasm/keeper (imported by github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app); to add:

Check failure on line 11 in app/ante.go

View workflow job for this annotation

GitHub Actions / Analyze

missing go.sum entry for module providing package github.com/CosmWasm/wasmd/x/wasm/keeper (imported by github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app); to add:
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"

Check failure on line 12 in app/ante.go

View workflow job for this annotation

GitHub Actions / test

missing go.sum entry for module providing package github.com/CosmWasm/wasmd/x/wasm/types (imported by github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app); to add:

Check failure on line 12 in app/ante.go

View workflow job for this annotation

GitHub Actions / build

missing go.sum entry for module providing package github.com/CosmWasm/wasmd/x/wasm/types (imported by github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app); to add:

Check failure on line 12 in app/ante.go

View workflow job for this annotation

GitHub Actions / Analyze

missing go.sum entry for module providing package github.com/CosmWasm/wasmd/x/wasm/types (imported by github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app); to add:

Check failure on line 12 in app/ante.go

View workflow job for this annotation

GitHub Actions / Analyze

missing go.sum entry for module providing package github.com/CosmWasm/wasmd/x/wasm/types (imported by github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app); to add:
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
Expand All @@ -23,13 +23,13 @@
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {

Check failure on line 26 in app/ante.go

View workflow job for this annotation

GitHub Actions / lint

options.AccountKeeper undefined (type HandlerOptions has no field or method AccountKeeper) (typecheck)
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
}
if options.BankKeeper == nil {

Check failure on line 29 in app/ante.go

View workflow job for this annotation

GitHub Actions / lint

options.BankKeeper undefined (type HandlerOptions has no field or method BankKeeper) (typecheck)
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
}
if options.SignModeHandler == nil {

Check failure on line 32 in app/ante.go

View workflow job for this annotation

GitHub Actions / lint

options.SignModeHandler undefined (type HandlerOptions has no field or method SignModeHandler) (typecheck)
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}
if options.WasmConfig == nil {
Expand All @@ -39,7 +39,7 @@
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder")
}

sigGasConsumer := options.SigGasConsumer

Check failure on line 42 in app/ante.go

View workflow job for this annotation

GitHub Actions / lint

options.SigGasConsumer undefined (type HandlerOptions has no field or method SigGasConsumer) (typecheck)
if sigGasConsumer == nil {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
}
Expand All @@ -48,14 +48,14 @@
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),

Check failure on line 51 in app/ante.go

View workflow job for this annotation

GitHub Actions / lint

options.ExtensionOptionChecker undefined (type HandlerOptions has no field or method ExtensionOptionChecker) (typecheck)
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),

Check failure on line 54 in app/ante.go

View workflow job for this annotation

GitHub Actions / lint

options.AccountKeeper undefined (type HandlerOptions has no field or method AccountKeeper) (typecheck)
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),

Check failure on line 55 in app/ante.go

View workflow job for this annotation

GitHub Actions / lint

options.AccountKeeper undefined (type HandlerOptions has no field or method AccountKeeper) (typecheck)
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),

Check failure on line 56 in app/ante.go

View workflow job for this annotation

GitHub Actions / lint

options.AccountKeeper undefined (type HandlerOptions has no field or method AccountKeeper) (typecheck)
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),

Check failure on line 58 in app/ante.go

View workflow job for this annotation

GitHub Actions / lint

options.AccountKeeper undefined (type HandlerOptions has no field or method AccountKeeper) (typecheck)
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
Expand Down
423 changes: 205 additions & 218 deletions app/app.go

Large diffs are not rendered by default.

53 changes: 11 additions & 42 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@ import (
"testing"
"time"

db "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
tmtypes "github.com/cometbft/cometbft/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/ibc-go/v6/testing/mock"
"github.com/stretchr/testify/assert"
"github.com/cosmos/ibc-go/v7/testing/mock"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"
db "github.com/tendermint/tm-db"
alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types"

abci "github.com/tendermint/tendermint/abci/types"
abci "github.com/cometbft/cometbft/abci/types"

"github.com/CosmWasm/wasmd/x/wasm"
)
Expand All @@ -30,7 +29,7 @@ var emptyWasmOpts []wasm.Option

func TestWasmdExport(t *testing.T) {
db := db.NewMemDB()
gapp := NewMigalooApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, make(map[int64]bool), DefaultNodeHome, 0, MakeEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts)
gapp := NewMigalooApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, make(map[int64]bool), DefaultNodeHome, 0, MakeEncodingConfig(), EmptyBaseAppOptions{}, emptyWasmOpts)
// generate validator private/public key
privVal := mock.NewPV()
pubKey, err := privVal.GetPubKey()
Expand Down Expand Up @@ -65,15 +64,15 @@ func TestWasmdExport(t *testing.T) {
gapp.Commit()

// Making a new app object with the db, so that initchain hasn't been called
newGapp := NewMigalooApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts)
_, err = newGapp.ExportAppStateAndValidators(false, []string{})
newGapp := NewMigalooApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeEncodingConfig(), EmptyBaseAppOptions{}, emptyWasmOpts)
_, err = newGapp.ExportAppStateAndValidators(false, []string{}, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
}

// ensure that blocked addresses are properly set in bank keeper
func TestBlockedAddrs(t *testing.T) {
db := db.NewMemDB()
gapp := NewMigalooApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, make(map[int64]bool), DefaultNodeHome, 0, MakeEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, emptyWasmOpts)
gapp := NewMigalooApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, make(map[int64]bool), DefaultNodeHome, 0, MakeEncodingConfig(), EmptyBaseAppOptions{}, emptyWasmOpts)

for acc := range maccPerms {
if acc == alliancemoduletypes.ModuleName {
Expand All @@ -92,37 +91,6 @@ func TestGetMaccPerms(t *testing.T) {
require.Equal(t, maccPerms, dup, "duplicated module account permissions differed from actual module account permissions")
}

func TestGetEnabledProposals(t *testing.T) {
cases := map[string]struct {
proposalsEnabled string
specificEnabled string
expected []wasm.ProposalType
}{
"all disabled": {
proposalsEnabled: "false",
expected: wasm.DisableAllProposals,
},
"all enabled": {
proposalsEnabled: "true",
expected: wasm.EnableAllProposals,
},
"some enabled": {
proposalsEnabled: "okay",
specificEnabled: "StoreCode,InstantiateContract",
expected: []wasm.ProposalType{wasm.ProposalTypeStoreCode, wasm.ProposalTypeInstantiateContract},
},
}

for name, tc := range cases {
t.Run(name, func(t *testing.T) {
ProposalsEnabled = tc.proposalsEnabled
EnableSpecificProposals = tc.specificEnabled
proposals := GetEnabledProposals()
assert.Equal(t, tc.expected, proposals)
})
}
}

func SetupGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, _ []wasm.Option, app *MigalooApp, balances ...banktypes.Balance) GenesisState {
genesisState := NewDefaultGenesisState()
// set genesis accounts
Expand Down Expand Up @@ -174,7 +142,8 @@ func SetupGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []au
})

// update total supply
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{})
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply,
[]banktypes.Metadata{}, []banktypes.SendEnabled{})
genesisState[banktypes.ModuleName] = app.appCodec.MustMarshalJSON(bankGenesis)

return genesisState
Expand Down
7 changes: 3 additions & 4 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"log"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -16,7 +16,7 @@ import (
// ExportAppStateAndValidators exports the state of the application for a genesis
// file.
func (app *MigalooApp) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string,
forZeroHeight bool, jailAllowedAddrs, modulesToExport []string,
) (servertypes.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
Expand All @@ -28,8 +28,7 @@ func (app *MigalooApp) ExportAppStateAndValidators(
height = 0
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
}

genState := app.mm.ExportGenesis(ctx, app.appCodec)
genState := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
appState, err := json.MarshalIndent(genState, "", " ")
if err != nil {
return servertypes.ExportedApp{}, err
Expand Down
83 changes: 44 additions & 39 deletions app/sim_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package app

import (
"cosmossdk.io/simapp"
"encoding/json"
"fmt"
"os"
"path/filepath"
"testing"
"time"

"github.com/CosmWasm/wasmd/x/wasm"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simapp"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/cosmos/cosmos-sdk/types/module"
Expand All @@ -20,29 +21,30 @@ import (
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/simulation"
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/CosmWasm/wasmd/x/wasm"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"os"
"path/filepath"
"testing"
"time"
)

// Get flags every time the simulator is run
func init() {
simapp.GetSimulatorFlags()
simcli.GetSimulatorFlags()
}

type StoreKeysPrefixes struct {
Expand All @@ -52,8 +54,9 @@ type StoreKeysPrefixes struct {
}

// SetupSimulation wraps simapp.SetupSimulation in order to create any export directory if they do not exist yet
func SetupSimulation(dirPrefix, dbName string) (simtypes.Config, dbm.DB, string, log.Logger, bool, error) {
config, db, dir, logger, skip, err := simapp.SetupSimulation(dirPrefix, dbName)
func SetupSimulation(dirPrefix, dbName string, verbose bool, skip bool) (simtypes.Config, dbm.DB, string, log.Logger, bool, error) {
config := simcli.NewConfigFromFlags()
db, dir, logger, skip, err := simtestutil.SetupSimulation(config, dirPrefix, dbName, verbose, skip)
if err != nil {
return simtypes.Config{}, nil, "", nil, false, err
}
Expand Down Expand Up @@ -102,7 +105,7 @@ func fauxMerkleModeOpt(bapp *baseapp.BaseApp) {
}

func TestAppImportExport(t *testing.T) {
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-sim", "Simulation")
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-sim", "Simulation", simcli.FlagVerboseValue, simcli.FlagEnabledValue)
if skip {
t.Skip("skipping application import/export simulation")
}
Expand All @@ -114,46 +117,46 @@ func TestAppImportExport(t *testing.T) {
}()

encConf := MakeEncodingConfig()
app := NewMigalooApp(logger, db, nil, true, map[int64]bool{}, dir, simapp.FlagPeriodValue, encConf, wasm.EnableAllProposals, EmptyBaseAppOptions{}, nil, fauxMerkleModeOpt)
app := NewMigalooApp(logger, db, nil, true, map[int64]bool{}, dir, simcli.FlagPeriodValue, encConf, EmptyBaseAppOptions{}, nil, fauxMerkleModeOpt)
require.Equal(t, appName, app.Name())

// Run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(
t,
os.Stdout,
app.BaseApp,
AppStateFn(app.AppCodec(), app.SimulationManager()),
AppStateFn(app.AppCodec(), app.SimulationManager(), app.DefaultGenesis()),
simtypes.RandomAccounts,
simapp.SimulationOperations(app, app.AppCodec(), config),
app.ModuleAccountAddrs(),
simtestutil.SimulationOperations(app, app.AppCodec(), config),
app.BlockedModuleAccountAddrs(),
config,
app.AppCodec(),
)

// export state and simParams before the simulation error is checked
err = simapp.CheckExportSimulation(app, config, simParams)
err = simtestutil.CheckExportSimulation(app, config, simParams)
require.NoError(t, err)
require.NoError(t, simErr)

if config.Commit {
simapp.PrintStats(db)
simtestutil.PrintStats(db)
}

t.Log("exporting genesis...")

exported, err := app.ExportAppStateAndValidators(false, []string{})
exported, err := app.ExportAppStateAndValidators(false, []string{}, []string{})
require.NoError(t, err)

t.Log("importing genesis...")

_, newDB, newDir, _, _, err := SetupSimulation("leveldb-app-sim-2", "Simulation-2")
_, newDB, newDir, _, _, err := SetupSimulation("leveldb-app-sim-2", "Simulation-2", simcli.FlagVerboseValue, simcli.FlagEnabledValue)
require.NoError(t, err, "simulation setup failed")

defer func() {
newDB.Close()
require.NoError(t, os.RemoveAll(newDir))
}()
newApp := NewMigalooApp(logger, newDB, nil, true, map[int64]bool{}, newDir, simapp.FlagPeriodValue, encConf, wasm.EnableAllProposals, EmptyBaseAppOptions{}, nil, fauxMerkleModeOpt)
newApp := NewMigalooApp(logger, newDB, nil, true, map[int64]bool{}, newDir, simcli.FlagPeriodValue, encConf, EmptyBaseAppOptions{}, nil, fauxMerkleModeOpt)
require.Equal(t, appName, newApp.Name())

var genesisState GenesisState
Expand Down Expand Up @@ -184,11 +187,13 @@ func TestAppImportExport(t *testing.T) {
{app.keys[govtypes.StoreKey], newApp.keys[govtypes.StoreKey], [][]byte{}},
{app.keys[evidencetypes.StoreKey], newApp.keys[evidencetypes.StoreKey], [][]byte{}},
{app.keys[capabilitytypes.StoreKey], newApp.keys[capabilitytypes.StoreKey], [][]byte{}},
{app.keys[ibchost.StoreKey], newApp.keys[ibchost.StoreKey], [][]byte{}},
{app.keys[ibcexported.StoreKey], newApp.keys[ibcexported.StoreKey], [][]byte{}},
{app.keys[ibctransfertypes.StoreKey], newApp.keys[ibctransfertypes.StoreKey], [][]byte{}},
{app.keys[authzkeeper.StoreKey], newApp.keys[authzkeeper.StoreKey], [][]byte{}},
{app.keys[feegrant.StoreKey], newApp.keys[feegrant.StoreKey], [][]byte{}},
{app.keys[wasm.StoreKey], newApp.keys[wasm.StoreKey], [][]byte{}},
{app.keys[consensusparamtypes.StoreKey], newApp.keys[consensusparamtypes.StoreKey], [][]byte{}},
{app.keys[crisistypes.StoreKey], newApp.keys[crisistypes.StoreKey], [][]byte{}},
}

// delete persistent tx counter value
Expand All @@ -208,7 +213,7 @@ func TestAppImportExport(t *testing.T) {
}

func TestFullAppSimulation(t *testing.T) {
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-sim", "Simulation")
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-sim", "Simulation", simcli.FlagVerboseValue, simcli.FlagEnabledValue)
if skip {
t.Skip("skipping application simulation")
}
Expand All @@ -219,41 +224,41 @@ func TestFullAppSimulation(t *testing.T) {
require.NoError(t, os.RemoveAll(dir))
}()
encConf := MakeEncodingConfig()
app := NewMigalooApp(logger, db, nil, true, map[int64]bool{}, t.TempDir(), simapp.FlagPeriodValue,
encConf, wasm.EnableAllProposals, simapp.EmptyAppOptions{}, nil, fauxMerkleModeOpt)
app := NewMigalooApp(logger, db, nil, true, map[int64]bool{}, t.TempDir(), simcli.FlagPeriodValue,
encConf, simtestutil.EmptyAppOptions{}, nil, fauxMerkleModeOpt)
require.Equal(t, "MigalooApp", app.Name())

// run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(
t,
os.Stdout,
app.BaseApp,
AppStateFn(app.appCodec, app.SimulationManager()),
AppStateFn(app.AppCodec(), app.SimulationManager(), app.DefaultGenesis()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simapp.SimulationOperations(app, app.AppCodec(), config),
simtestutil.SimulationOperations(app, app.AppCodec(), config),
app.ModuleAccountAddrs(),
config,
app.AppCodec(),
)

// export state and simParams before the simulation error is checked
err = simapp.CheckExportSimulation(app, config, simParams)
err = simtestutil.CheckExportSimulation(app, config, simParams)
require.NoError(t, err)
require.NoError(t, simErr)

if config.Commit {
simapp.PrintStats(db)
simtestutil.PrintStats(db)
}
}

// AppStateFn returns the initial application state using a genesis or the simulation parameters.
// It panics if the user provides files for both of them.
// If a file is not given for the genesis or the sim params, it creates a randomized one.
func AppStateFn(codec codec.Codec, manager *module.SimulationManager) simtypes.AppStateFn {
func AppStateFn(codec codec.Codec, manager *module.SimulationManager, genesisState map[string]json.RawMessage) simtypes.AppStateFn {
// quick hack to setup app state genesis with our app modules
simapp.ModuleBasics = ModuleBasics
if simapp.FlagGenesisTimeValue == 0 { // always set to have a block time
simapp.FlagGenesisTimeValue = time.Now().Unix()
if simcli.FlagGenesisTimeValue == 0 { // always set to have a block time
simcli.FlagGenesisTimeValue = time.Now().Unix()
}
return simapp.AppStateFn(codec, manager)
return simtestutil.AppStateFn(codec, manager, genesisState)
}
6 changes: 3 additions & 3 deletions app/test_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
ibctransferkeeper "github.com/cosmos/ibc-go/v6/modules/apps/transfer/keeper"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

"github.com/CosmWasm/wasmd/x/wasm"
)
Expand Down Expand Up @@ -52,7 +52,7 @@ func (s TestSupport) ScopedTransferKeeper() capabilitykeeper.ScopedKeeper {
return s.app.ScopedTransferKeeper
}

func (s TestSupport) StakingKeeper() stakingkeeper.Keeper {
func (s TestSupport) StakingKeeper() *stakingkeeper.Keeper {
return s.app.StakingKeeper
}

Expand Down
Loading
Loading