-
Notifications
You must be signed in to change notification settings - Fork 0
/
epochs.go
62 lines (52 loc) · 1.34 KB
/
epochs.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
package keeper
import (
"testing"
tmdb "github.com/cometbft/cometbft-db"
"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"
"github.com/furyanprotocol/v4-chain/protocol/x/epochs/keeper"
"github.com/furyanprotocol/v4-chain/protocol/x/epochs/types"
)
const (
TestEpochInfoName = "name"
TestEpochDuration = uint32(20)
TestCreateEpochBlockTimeSec = 1656900000
)
func EpochsKeeper(
t testing.TB,
) (
ctx sdk.Context,
epochsKeeper *keeper.Keeper,
storeKey storetypes.StoreKey,
) {
ctx = initKeepers(t, func(
db *tmdb.MemDB,
registry codectypes.InterfaceRegistry,
cdc *codec.ProtoCodec,
stateStore storetypes.CommitMultiStore,
transientStoreKey storetypes.StoreKey,
) []GenesisInitializer {
epochsKeeper, storeKey = createEpochsKeeper(
stateStore,
db,
cdc,
)
return []GenesisInitializer{epochsKeeper}
})
return ctx, epochsKeeper, storeKey
}
func createEpochsKeeper(
stateStore storetypes.CommitMultiStore,
db *tmdb.MemDB,
cdc *codec.ProtoCodec,
) (*keeper.Keeper, storetypes.StoreKey) {
storeKey := sdk.NewKVStoreKey(types.StoreKey)
stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db)
k := keeper.NewKeeper(
cdc,
storeKey,
)
return k, storeKey
}