2022-08-25 16:51:14 -07:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-09-05 16:03:12 -07:00
|
|
|
"colinear/x/colinear-core/keeper"
|
|
|
|
"colinear/x/colinear-core/types"
|
2022-08-31 23:09:36 -07:00
|
|
|
|
2022-08-25 16:51:14 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/store"
|
|
|
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
|
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
|
|
|
tmdb "github.com/tendermint/tm-db"
|
|
|
|
)
|
|
|
|
|
2022-09-05 16:03:12 -07:00
|
|
|
func ColinearcoreKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
2022-08-25 16:51:14 -07:00
|
|
|
storeKey := sdk.NewKVStoreKey(types.StoreKey)
|
|
|
|
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)
|
|
|
|
|
|
|
|
db := tmdb.NewMemDB()
|
|
|
|
stateStore := store.NewCommitMultiStore(db)
|
|
|
|
stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db)
|
|
|
|
stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil)
|
|
|
|
require.NoError(t, stateStore.LoadLatestVersion())
|
|
|
|
|
|
|
|
registry := codectypes.NewInterfaceRegistry()
|
|
|
|
cdc := codec.NewProtoCodec(registry)
|
|
|
|
|
|
|
|
paramsSubspace := typesparams.NewSubspace(cdc,
|
|
|
|
types.Amino,
|
|
|
|
storeKey,
|
|
|
|
memStoreKey,
|
2022-09-05 16:03:12 -07:00
|
|
|
"ColinearcoreParams",
|
2022-08-25 16:51:14 -07:00
|
|
|
)
|
2022-08-31 23:09:36 -07:00
|
|
|
|
2022-08-25 16:51:14 -07:00
|
|
|
k := keeper.NewKeeper(
|
|
|
|
cdc,
|
|
|
|
storeKey,
|
|
|
|
memStoreKey,
|
|
|
|
paramsSubspace,
|
2022-08-31 23:09:36 -07:00
|
|
|
// probably fix this later o_0
|
|
|
|
*new(types.BankKeeper),
|
2022-08-25 16:51:14 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
|
|
|
|
|
|
|
|
// Initialize params
|
|
|
|
k.SetParams(ctx, types.DefaultParams())
|
|
|
|
|
|
|
|
return k, ctx
|
|
|
|
}
|