-
Notifications
You must be signed in to change notification settings - Fork 197
/
consumer.go
36 lines (32 loc) · 1.7 KB
/
consumer.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
package testutil
import (
"time"
ibctypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ccvprovidertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types"
ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types"
)
// This function creates consumer module genesis state that is used as starting point for modifications
// that allow Stride chain to be started locally without having to start the provider chain and the relayer.
// It is also used in tests that are starting the chain node.
func CreateMinimalConsumerTestGenesis() *ccvtypes.ConsumerGenesisState {
genesisState := ccvtypes.DefaultConsumerGenesisState()
genesisState.Params.Enabled = true
genesisState.NewChain = true
genesisState.Provider.ClientState = ccvprovidertypes.DefaultParams().TemplateClient
genesisState.Provider.ClientState.ChainId = "stride"
genesisState.Provider.ClientState.LatestHeight = ibctypes.Height{RevisionNumber: 0, RevisionHeight: 1}
trustPeriod, err := ccvtypes.CalculateTrustPeriod(genesisState.Params.UnbondingPeriod, ccvprovidertypes.DefaultTrustingPeriodFraction)
if err != nil {
panic("provider client trusting period error")
}
genesisState.Provider.ClientState.TrustingPeriod = trustPeriod
genesisState.Provider.ClientState.UnbondingPeriod = genesisState.Params.UnbondingPeriod
genesisState.Provider.ClientState.MaxClockDrift = ccvprovidertypes.DefaultMaxClockDrift
genesisState.Provider.ConsensusState = &ibctmtypes.ConsensusState{
Timestamp: time.Now().UTC(),
Root: types.MerkleRoot{Hash: []byte("dummy")},
}
return genesisState
}