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

Update simulation test #2984

Merged
merged 11 commits into from
Dec 20, 2024
Merged
Changes from 10 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
42 changes: 21 additions & 21 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
coinswaptypes "mods.irisnet.org/modules/coinswap/types"
htlctypes "mods.irisnet.org/modules/htlc/types"
Expand All @@ -33,7 +34,6 @@ import (
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand All @@ -46,7 +46,6 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
)

// AppChainID hardcoded chainID for simulation
Expand Down Expand Up @@ -129,8 +128,6 @@ func TestAppImportExport(t *testing.T) {
config := simcli.NewConfigFromFlags()
config.ChainID = AppChainID

sdk.DefaultBondDenom = iristypes.NativeToken.Symbol

db, dir, logger, skip, err := simtestutil.SetupSimulation(
config,
"goleveldb-app-sim",
Expand Down Expand Up @@ -216,8 +213,17 @@ func TestAppImportExport(t *testing.T) {

ctxA := app.NewContextLegacy(true, tmproto.Header{Height: app.LastBlockHeight()})
ctxB := newApp.NewContextLegacy(true, tmproto.Header{Height: app.LastBlockHeight()})
newApp.mm.InitGenesis(ctxB, app.AppCodec(), genesisState)
newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)
_, err = newApp.mm.InitGenesis(ctxB, app.AppCodec(), genesisState)
if err != nil {
wangjiulian marked this conversation as resolved.
Show resolved Hide resolved
if strings.Contains(err.Error(), "validator set is empty after InitGenesis") {
logger.Info("Skipping simulation as all validators have been unbonded")
logger.Info("err", err, "stacktrace", string(debug.Stack()))
return
}
}
require.NoError(t, err)
err = newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)
require.NoError(t, err)

fmt.Printf("comparing stores...\n")

Expand All @@ -227,10 +233,11 @@ func TestAppImportExport(t *testing.T) {
app.AppKeepers.KvStoreKeys()[stakingtypes.StoreKey], newApp.AppKeepers.KvStoreKeys()[stakingtypes.StoreKey],
[][]byte{
stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey,
stakingtypes.HistoricalInfoKey,
stakingtypes.HistoricalInfoKey, stakingtypes.UnbondingIDKey, stakingtypes.UnbondingIndexKey,
stakingtypes.UnbondingTypeKey, stakingtypes.ValidatorUpdatesKey,
},
}, // ordering may change but it doesn't matter
{app.AppKeepers.KvStoreKeys()[slashingtypes.StoreKey], newApp.AppKeepers.KvStoreKeys()[slashingtypes.StoreKey], [][]byte{}},
{app.AppKeepers.KvStoreKeys()[slashingtypes.StoreKey], newApp.AppKeepers.KvStoreKeys()[slashingtypes.StoreKey], [][]byte{slashingtypes.ValidatorMissedBlockBitmapKeyPrefix}},
{app.AppKeepers.KvStoreKeys()[minttypes.StoreKey], newApp.AppKeepers.KvStoreKeys()[minttypes.StoreKey], [][]byte{}},
{app.AppKeepers.KvStoreKeys()[distrtypes.StoreKey], newApp.AppKeepers.KvStoreKeys()[distrtypes.StoreKey], [][]byte{}},
{
Expand All @@ -242,7 +249,6 @@ func TestAppImportExport(t *testing.T) {
{app.AppKeepers.KvStoreKeys()[govtypes.StoreKey], newApp.AppKeepers.KvStoreKeys()[govtypes.StoreKey], [][]byte{}},
{app.AppKeepers.KvStoreKeys()[evidencetypes.StoreKey], newApp.AppKeepers.KvStoreKeys()[evidencetypes.StoreKey], [][]byte{}},
{app.AppKeepers.KvStoreKeys()[capabilitytypes.StoreKey], newApp.AppKeepers.KvStoreKeys()[capabilitytypes.StoreKey], [][]byte{}},
{app.AppKeepers.KvStoreKeys()[ibcexported.StoreKey], newApp.AppKeepers.KvStoreKeys()[ibcexported.StoreKey], [][]byte{}},
{app.AppKeepers.KvStoreKeys()[ibctransfertypes.StoreKey], newApp.AppKeepers.KvStoreKeys()[ibctransfertypes.StoreKey], [][]byte{}},

// check irismod module
Expand Down Expand Up @@ -278,17 +284,12 @@ func TestAppImportExport(t *testing.T) {
skp.A,
skp.B,
)
require.Equal(
t,
len(failedKVAs),
0,
simtestutil.GetSimulationLog(
skp.A.Name(),
app.SimulationManager().StoreDecoders,
failedKVAs,
failedKVBs,
),
)
if !assert.Equal(t, 0, len(failedKVAs), simtestutil.GetSimulationLog(skp.A.Name(), app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs)) {
for _, v := range failedKVAs {
t.Logf("store missmatch: %q\n", v)
}
t.FailNow()
}
}
}

Expand Down Expand Up @@ -396,7 +397,6 @@ func TestAppStateDeterminism(t *testing.T) {
if !simcli.FlagEnabledValue {
t.Skip("skipping application simulation")
}
sdk.DefaultBondDenom = iristypes.NativeToken.Symbol

config := simcli.NewConfigFromFlags()
config.InitialBlockHeight = 1
Expand Down
Loading