57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package keeper_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"cosmossdk.io/core/address"
|
|
storetypes "cosmossdk.io/store/types"
|
|
addresscodec "git.cw.tr/mukan-network/mukan-sdk/codec/address"
|
|
"git.cw.tr/mukan-network/mukan-sdk/runtime"
|
|
"git.cw.tr/mukan-network/mukan-sdk/testutil"
|
|
sdk "git.cw.tr/mukan-network/mukan-sdk/types"
|
|
moduletestutil "git.cw.tr/mukan-network/mukan-sdk/types/module/testutil"
|
|
authtypes "git.cw.tr/mukan-network/mukan-sdk/x/auth/types"
|
|
|
|
"mukan/x/qpos/keeper"
|
|
module "mukan/x/qpos/module"
|
|
"mukan/x/qpos/types"
|
|
)
|
|
|
|
type fixture struct {
|
|
ctx context.Context
|
|
keeper keeper.Keeper
|
|
addressCodec address.Codec
|
|
}
|
|
|
|
func initFixture(t *testing.T) *fixture {
|
|
t.Helper()
|
|
|
|
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{})
|
|
addressCodec := addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())
|
|
storeKey := storetypes.NewKVStoreKey(types.StoreKey)
|
|
|
|
storeService := runtime.NewKVStoreService(storeKey)
|
|
ctx := testutil.DefaultContextWithDB(t, storeKey, storetypes.NewTransientStoreKey("transient_test")).Ctx
|
|
|
|
authority := authtypes.NewModuleAddress(types.GovModuleName)
|
|
|
|
k := keeper.NewKeeper(
|
|
storeService,
|
|
encCfg.Codec,
|
|
addressCodec,
|
|
authority,
|
|
nil,
|
|
)
|
|
|
|
// Initialize params
|
|
if err := k.Params.Set(ctx, types.DefaultParams()); err != nil {
|
|
t.Fatalf("failed to set params: %v", err)
|
|
}
|
|
|
|
return &fixture{
|
|
ctx: ctx,
|
|
keeper: k,
|
|
addressCodec: addressCodec,
|
|
}
|
|
}
|