diff --git a/x/btcstaking/keeper/genesis_test.go b/x/btcstaking/keeper/genesis_test.go index 9083f385..574cb87c 100644 --- a/x/btcstaking/keeper/genesis_test.go +++ b/x/btcstaking/keeper/genesis_test.go @@ -6,53 +6,36 @@ import ( "strings" "testing" - "cosmossdk.io/core/header" "cosmossdk.io/log" "cosmossdk.io/store" storemetrics "cosmossdk.io/store/metrics" - "github.com/btcsuite/btcd/chaincfg" dbm "github.com/cosmos/cosmos-db" - "github.com/cosmos/cosmos-sdk/runtime" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/stretchr/testify/require" - storetypes "cosmossdk.io/store/types" - "github.com/babylonlabs-io/babylon/app" v1 "github.com/babylonlabs-io/babylon/app/upgrades/v1" testnetdata "github.com/babylonlabs-io/babylon/app/upgrades/v1/testnet" "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/babylonlabs-io/babylon/testutil/helper" + testutilk "github.com/babylonlabs-io/babylon/testutil/keeper" btclightclientt "github.com/babylonlabs-io/babylon/x/btclightclient/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" "github.com/babylonlabs-io/babylon/x/btcstaking/types" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" ) -func TestInitGenesis(t *testing.T) { - types.DefaultParams() - bbnApp := app.NewTmpBabylonApp() - - storeKey := storetypes.NewKVStoreKey(types.StoreKey) - +func TestInitGenesisWithSetParams(t *testing.T) { db := dbm.NewMemDB() stateStore := store.NewCommitMultiStore(db, log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) - stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) - require.NoError(t, stateStore.LoadLatestVersion()) - - ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) - ctx = ctx.WithHeaderInfo(header.Info{}) + k, ctx := testutilk.BTCStakingKeeperWithStore(t, db, stateStore, nil, nil, nil) - k := keeper.NewKeeper(bbnApp.AppCodec(), runtime.NewKVStoreService(storeKey), nil, nil, nil, &chaincfg.RegressionNetParams, authtypes.NewModuleAddress(govtypes.ModuleName).String()) err := k.InitGenesis(ctx, *types.DefaultGenesis()) require.NoError(t, err) params, err := v1.LoadBtcStakingParamsFromData(testnetdata.BtcStakingParamsStr) require.NoError(t, err) - err = k.SetParams(ctx, params[len(params)-1]) - require.NoError(t, err) + for _, p := range params { + err = k.SetParams(ctx, p) + require.NoError(t, err) + } } func TestExportGenesis(t *testing.T) {