Skip to content

Commit

Permalink
Merge pull request #2984 from irisnet/feature/up_simulate_1
Browse files Browse the repository at this point in the history
Update simulation test
  • Loading branch information
mitch1024 authored Dec 20, 2024
2 parents 684f347 + 6cf0680 commit c1cec5f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
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 {
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
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ require (
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/iavl v1.2.0 // indirect
github.com/evmos/ethermint v0.22.0
mods.irisnet.org/modules/coinswap v0.0.0-20241217080151-0ad41be03ac6
mods.irisnet.org/modules/farm v0.0.0-20241217080151-0ad41be03ac6
mods.irisnet.org/modules/htlc v0.0.0-20241217080151-0ad41be03ac6
mods.irisnet.org/modules/mt v0.0.0-20241217080151-0ad41be03ac6
mods.irisnet.org/modules/nft v0.0.0-20241217080151-0ad41be03ac6
mods.irisnet.org/modules/oracle v0.0.0-20241217080151-0ad41be03ac6
mods.irisnet.org/modules/random v0.0.0-20241217080151-0ad41be03ac6
mods.irisnet.org/modules/record v0.0.0-20241217080151-0ad41be03ac6
mods.irisnet.org/modules/service v0.0.0-20241217080151-0ad41be03ac6
mods.irisnet.org/modules/token v0.0.0-20241217080151-0ad41be03ac6
mods.irisnet.org/modules/coinswap v0.0.0-20241219091434-96f998e7149d
mods.irisnet.org/modules/farm v0.0.0-20241219091434-96f998e7149d
mods.irisnet.org/modules/htlc v0.0.0-20241219091434-96f998e7149d
mods.irisnet.org/modules/mt v0.0.0-20241219091434-96f998e7149d
mods.irisnet.org/modules/nft v0.0.0-20241219091434-96f998e7149d
mods.irisnet.org/modules/oracle v0.0.0-20241219091434-96f998e7149d
mods.irisnet.org/modules/random v0.0.0-20241219091434-96f998e7149d
mods.irisnet.org/modules/record v0.0.0-20241219091434-96f998e7149d
mods.irisnet.org/modules/service v0.0.0-20241219091434-96f998e7149d
mods.irisnet.org/modules/token v0.0.0-20241219091434-96f998e7149d
)

require (
Expand Down
40 changes: 20 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2065,26 +2065,26 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
mods.irisnet.org/api v0.0.0-20241121030837-903540d1123f h1:tJoTbTqFBZUnCLL+juHEuQLNNdftSXwSlqGoKa8OOxw=
mods.irisnet.org/api v0.0.0-20241121030837-903540d1123f/go.mod h1:TpMaRRYSpqsXdeX4gDVFRj9ggedQ60Zcjs4iE2DIhsc=
mods.irisnet.org/modules/coinswap v0.0.0-20241217080151-0ad41be03ac6 h1:8QnufoVSKUdiLPqJwByZF6yz5zt9qyhSaT08No50pMA=
mods.irisnet.org/modules/coinswap v0.0.0-20241217080151-0ad41be03ac6/go.mod h1:nv52g5ZDWv/C1ydtxLygP2wSYz6M4OuF6BygKy7RqGA=
mods.irisnet.org/modules/farm v0.0.0-20241217080151-0ad41be03ac6 h1:SA28lvYjEgOylkZJyuRVDIK4uGBHmtMGJvyAshUJJFk=
mods.irisnet.org/modules/farm v0.0.0-20241217080151-0ad41be03ac6/go.mod h1:yYrnhmxDCnvI45u1cpeRZ2GPJUmRK+8KFXDtOJGpENE=
mods.irisnet.org/modules/htlc v0.0.0-20241217080151-0ad41be03ac6 h1:JPzUkLdXY/0YzlgQ4wsmiI35Karrssb77dopt67qvqU=
mods.irisnet.org/modules/htlc v0.0.0-20241217080151-0ad41be03ac6/go.mod h1:2pWkSnxVKCzB3WH+q47rKffY4Plma+mRTGSWd4jfbp8=
mods.irisnet.org/modules/mt v0.0.0-20241217080151-0ad41be03ac6 h1:DyW+fBjjzJ4/h60sfvL0nkewudIZFRFPGvAZPj+8a+c=
mods.irisnet.org/modules/mt v0.0.0-20241217080151-0ad41be03ac6/go.mod h1:Dw1zm350HiRuNjrnwZnV4XGB8PNf1SXmjGJA5Xslg0Q=
mods.irisnet.org/modules/nft v0.0.0-20241217080151-0ad41be03ac6 h1:RHgx9ggA5/lsNKXvQ7ezJpCfJBhKjlBBAfoaOTKNMnU=
mods.irisnet.org/modules/nft v0.0.0-20241217080151-0ad41be03ac6/go.mod h1:VjySqJfECBW8cApFB8W66Yk6tMR2oJEc7FTDaHfeg8I=
mods.irisnet.org/modules/oracle v0.0.0-20241217080151-0ad41be03ac6 h1:1Xj4j7f639GMZ+MAbwNljQb0DZ5IdXDqQYNoDlppVXk=
mods.irisnet.org/modules/oracle v0.0.0-20241217080151-0ad41be03ac6/go.mod h1:XAGzG55xpV01PwvryVPeaHtARZIqEUJcMv/vxaVcVC0=
mods.irisnet.org/modules/random v0.0.0-20241217080151-0ad41be03ac6 h1:ScX6qHG3V49eQHkeQmJ5awp7I8ixou+obxxWd4/wTcU=
mods.irisnet.org/modules/random v0.0.0-20241217080151-0ad41be03ac6/go.mod h1:1ele5fpZ/rFMbwu1LTz2MwDg3sJDYcCtDW5SDfYRpTg=
mods.irisnet.org/modules/record v0.0.0-20241217080151-0ad41be03ac6 h1:PJu+56Be8F+mPj35jqeMvXl/bRZDtwrF9GL6j0w5ivQ=
mods.irisnet.org/modules/record v0.0.0-20241217080151-0ad41be03ac6/go.mod h1:n8gRooDvJ5B44EJRZ+UlDz0GcXQeNwjH2tjpnVx7nd8=
mods.irisnet.org/modules/service v0.0.0-20241217080151-0ad41be03ac6 h1:U6IzrFgN8GXhdNHXxA5isDgQX7DeSfeVDqvLzs6cc4o=
mods.irisnet.org/modules/service v0.0.0-20241217080151-0ad41be03ac6/go.mod h1:B1nKRNYn1VLqpvNbmbDSYagqL56sj0MIceXJi/DKg6s=
mods.irisnet.org/modules/token v0.0.0-20241217080151-0ad41be03ac6 h1:hlzR6ghnSujPC9VCwrpBVU6cBb+M9KyfbJz5SrnIef8=
mods.irisnet.org/modules/token v0.0.0-20241217080151-0ad41be03ac6/go.mod h1:fHJzeEBPhE9vaa4aye90+WFtHjZyGRvkWRpJeBSc9/k=
mods.irisnet.org/modules/coinswap v0.0.0-20241219091434-96f998e7149d h1:9ZYTaFkjlWlNU3+CJSr7GlC+7ym03/Yktuvk2oyWbqQ=
mods.irisnet.org/modules/coinswap v0.0.0-20241219091434-96f998e7149d/go.mod h1:nv52g5ZDWv/C1ydtxLygP2wSYz6M4OuF6BygKy7RqGA=
mods.irisnet.org/modules/farm v0.0.0-20241219091434-96f998e7149d h1:nfIpN3UdLLSKlT6yjDusPFk5d5btLuDR80wattHN6/o=
mods.irisnet.org/modules/farm v0.0.0-20241219091434-96f998e7149d/go.mod h1:yYrnhmxDCnvI45u1cpeRZ2GPJUmRK+8KFXDtOJGpENE=
mods.irisnet.org/modules/htlc v0.0.0-20241219091434-96f998e7149d h1:nJ9QTBaVEY32ll7fFuhBDCaCeZX3zlnr8f4Q7rijIU4=
mods.irisnet.org/modules/htlc v0.0.0-20241219091434-96f998e7149d/go.mod h1:2pWkSnxVKCzB3WH+q47rKffY4Plma+mRTGSWd4jfbp8=
mods.irisnet.org/modules/mt v0.0.0-20241219091434-96f998e7149d h1:BibcvFarK2gl+38ABWc82mBRzDXHTonSaMOjWrsF7qs=
mods.irisnet.org/modules/mt v0.0.0-20241219091434-96f998e7149d/go.mod h1:Dw1zm350HiRuNjrnwZnV4XGB8PNf1SXmjGJA5Xslg0Q=
mods.irisnet.org/modules/nft v0.0.0-20241219091434-96f998e7149d h1:4QA5IADh0E5s13xipzHQjmvCiTh+rwTjYkcHp5FcfoY=
mods.irisnet.org/modules/nft v0.0.0-20241219091434-96f998e7149d/go.mod h1:VjySqJfECBW8cApFB8W66Yk6tMR2oJEc7FTDaHfeg8I=
mods.irisnet.org/modules/oracle v0.0.0-20241219091434-96f998e7149d h1:TJ9ChS7i3eqJvysgB0xsA3f/nZNyDK+3R0581a5xQA8=
mods.irisnet.org/modules/oracle v0.0.0-20241219091434-96f998e7149d/go.mod h1:XAGzG55xpV01PwvryVPeaHtARZIqEUJcMv/vxaVcVC0=
mods.irisnet.org/modules/random v0.0.0-20241219091434-96f998e7149d h1:WrKK3faOWgye3850G4XT3RhcB2kvVmkjlNppf4hU3xc=
mods.irisnet.org/modules/random v0.0.0-20241219091434-96f998e7149d/go.mod h1:1ele5fpZ/rFMbwu1LTz2MwDg3sJDYcCtDW5SDfYRpTg=
mods.irisnet.org/modules/record v0.0.0-20241219091434-96f998e7149d h1:j77bqsJJi0unnUO80sBtHjbAUZlgJ3rPDT7FWQAxegk=
mods.irisnet.org/modules/record v0.0.0-20241219091434-96f998e7149d/go.mod h1:n8gRooDvJ5B44EJRZ+UlDz0GcXQeNwjH2tjpnVx7nd8=
mods.irisnet.org/modules/service v0.0.0-20241219091434-96f998e7149d h1:se/nr3FZXSrqfqozKyFUldjiI0b9koNkNxo2HX0ce8Y=
mods.irisnet.org/modules/service v0.0.0-20241219091434-96f998e7149d/go.mod h1:B1nKRNYn1VLqpvNbmbDSYagqL56sj0MIceXJi/DKg6s=
mods.irisnet.org/modules/token v0.0.0-20241219091434-96f998e7149d h1:hAKlXF0vYjQUkYz/fFz0c7pGPcYYPYFlrsp5l5Mf5nw=
mods.irisnet.org/modules/token v0.0.0-20241219091434-96f998e7149d/go.mod h1:fHJzeEBPhE9vaa4aye90+WFtHjZyGRvkWRpJeBSc9/k=
mods.irisnet.org/simapp v0.0.0-20241125071105-d76ae25d05d2 h1:9AGZYpMjpk1gItviL31vsehmen119HtcuOKwv8WWpZo=
mods.irisnet.org/simapp v0.0.0-20241125071105-d76ae25d05d2/go.mod h1:t7FSQJkJOgXq1/LdhpBeOu7TS8hLQkAMMx9fL5w53PY=
nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k=
Expand Down

0 comments on commit c1cec5f

Please sign in to comment.