/
subscription.go
93 lines (80 loc) · 2.78 KB
/
subscription.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package keeper
import (
"testing"
tmdb "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"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"
dualstakingkeeper "github.com/lavanet/lava/x/dualstaking/keeper"
epochstoragekeeper "github.com/lavanet/lava/x/epochstorage/keeper"
fixationkeeper "github.com/lavanet/lava/x/fixationstore/keeper"
planskeeper "github.com/lavanet/lava/x/plans/keeper"
projectskeeper "github.com/lavanet/lava/x/projects/keeper"
"github.com/lavanet/lava/x/subscription/keeper"
"github.com/lavanet/lava/x/subscription/types"
timerstorekeeper "github.com/lavanet/lava/x/timerstore/keeper"
"github.com/stretchr/testify/require"
)
func SubscriptionKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
storeKey := sdk.NewKVStoreKey(types.StoreKey)
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)
db := tmdb.NewMemDB()
stateStore := store.NewCommitMultiStore(db)
stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db)
stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil)
require.NoError(t, stateStore.LoadLatestVersion())
registry := codectypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(registry)
paramsSubspace := typesparams.NewSubspace(cdc,
types.Amino,
storeKey,
memStoreKey,
"SubscriptionParams",
)
paramsSubspaceEpochstorage := typesparams.NewSubspace(cdc,
types.Amino,
storeKey,
memStoreKey,
"EpochStorageParams",
)
paramsSubspaceProjects := typesparams.NewSubspace(cdc,
types.Amino,
storeKey,
memStoreKey,
"ProjectsParams",
)
paramsSubspacePlans := typesparams.NewSubspace(cdc,
types.Amino,
storeKey,
memStoreKey,
"PlansParams",
)
epochstorageKeeper := epochstoragekeeper.NewKeeper(cdc, nil, nil, paramsSubspaceEpochstorage, nil, nil, nil, nil)
tsKeeper := timerstorekeeper.NewKeeper(cdc)
fsKeeper := fixationkeeper.NewKeeper(cdc, tsKeeper, epochstorageKeeper.BlocksToSaveRaw)
k := keeper.NewKeeper(
cdc,
storeKey,
memStoreKey,
paramsSubspace,
nil,
nil,
epochstorageKeeper,
projectskeeper.NewKeeper(cdc, nil, nil, paramsSubspaceProjects, nil, fsKeeper),
planskeeper.NewKeeper(cdc, nil, nil, paramsSubspacePlans, nil, nil, fsKeeper, nil),
dualstakingkeeper.NewKeeper(cdc, nil, nil, paramsSubspace, nil, nil, mockAccountKeeper{}, nil, nil, fsKeeper),
nil,
fsKeeper,
tsKeeper,
nil,
)
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
// Initialize params
k.SetParams(ctx, types.DefaultParams())
return k, ctx
}