/
rstake.go
60 lines (50 loc) · 1.59 KB
/
rstake.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package keeper
import (
"sync"
"testing"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stafihub/stafihub/x/rstaking/keeper"
"github.com/stafihub/stafihub/x/rstaking/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
var (
rstakeStoreKey = sdk.NewKVStoreKey(types.StoreKey)
rstakeMemStoreKey = storetypes.NewMemoryStoreKey(types.MemStoreKey)
rstakeOnce sync.Once
)
func RStakingKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
rstakeOnce.Do(func() {
stateStore.MountStoreWithDB(rstakeStoreKey, storetypes.StoreTypeIAVL, db)
stateStore.MountStoreWithDB(rstakeMemStoreKey, storetypes.StoreTypeMemory, nil)
})
require.NoError(t, stateStore.LoadLatestVersion())
registry := codectypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(registry)
paramsSubspace := typesparams.NewSubspace(cdc,
types.Amino,
rstakeStoreKey,
rstakeMemStoreKey,
"RStakingParams",
)
sudoKeeper, _ := SudoKeeper(t)
k := keeper.NewKeeper(
cdc,
rstakeStoreKey,
rstakeMemStoreKey,
paramsSubspace,
BankKeeper,
sudoKeeper,
authtypes.FeeCollectorName,
)
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
// Initialize params
k.SetParams(ctx, types.DefaultParams())
return k, ctx
}