-
Notifications
You must be signed in to change notification settings - Fork 5
/
consumer.go
39 lines (35 loc) · 1.69 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
37
38
39
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"
ccvconsumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
ccvprovidertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
typesccv "github.com/cosmos/interchain-security/v3/x/ccv/types"
)
// This function creates consumer module genesis state that is used as starting point for modifications
// that allow Duality 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() *ccvconsumertypes.GenesisState {
genesisState := ccvconsumertypes.DefaultGenesisState()
genesisState.Params.Enabled = true
genesisState.NewChain = true
genesisState.ProviderClientState = ccvprovidertypes.DefaultParams().TemplateClient
genesisState.ProviderClientState.ChainId = "duality"
genesisState.ProviderClientState.LatestHeight = ibctypes.Height{
RevisionNumber: 0,
RevisionHeight: 1,
}
genesisState.ProviderClientState.TrustingPeriod, _ = typesccv.CalculateTrustPeriod(
genesisState.Params.UnbondingPeriod,
ccvprovidertypes.DefaultTrustingPeriodFraction,
)
genesisState.ProviderClientState.UnbondingPeriod = genesisState.Params.UnbondingPeriod
genesisState.ProviderClientState.MaxClockDrift = ccvprovidertypes.DefaultMaxClockDrift
genesisState.ProviderConsensusState = &ibctmtypes.ConsensusState{
Timestamp: time.Now().UTC(),
Root: types.MerkleRoot{Hash: []byte("dummy")},
}
return genesisState
}