Skip to content

Commit

Permalink
refactor consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 committed Mar 15, 2024
1 parent b0eeccd commit 0344628
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions cmd/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
pvm "github.com/cometbft/cometbft/privval"
tmtypes "github.com/cometbft/cometbft/types"
ccvconsumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types"
ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types"
"github.com/eve-network/eve/testutil"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -152,9 +151,9 @@ type GenesisData struct {
GenesisFile string
GenDoc *genutiltypes.AppGenesis
AppState map[string]json.RawMessage
ConsumerModuleState *ccvtypes.ConsumerGenesisState
ConsumerModuleState *ccvconsumertypes.GenesisState
}

func NewGenesisData(genesisFile string, genDoc *genutiltypes.AppGenesis, appState map[string]json.RawMessage, consumerModuleState *ccvtypes.ConsumerGenesisState) *GenesisData {
func NewGenesisData(genesisFile string, genDoc *genutiltypes.AppGenesis, appState map[string]json.RawMessage, consumerModuleState *ccvconsumertypes.GenesisState) *GenesisData {
return &GenesisData{GenesisFile: genesisFile, GenDoc: genDoc, AppState: appState, ConsumerModuleState: consumerModuleState}
}
17 changes: 9 additions & 8 deletions testutil/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ package testutil
import (
"time"

ibctypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck
"github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck
ibccommitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ccvconsumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types"
ccvprovidertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types"
"github.com/cosmos/interchain-security/v5/x/ccv/types"
)

func CreateMinimalConsumerTestGenesis() *ccvtypes.ConsumerGenesisState {
genesisState := ccvtypes.DefaultConsumerGenesisState()
func CreateMinimalConsumerTestGenesis() *ccvconsumertypes.GenesisState {
genesisState := ccvconsumertypes.DefaultGenesisState()
genesisState.Params.Enabled = true
genesisState.NewChain = true
genesisState.Provider.ClientState = ccvprovidertypes.DefaultParams().TemplateClient
genesisState.Provider.ClientState.ChainId = "eve"
genesisState.Provider.ClientState.LatestHeight = ibctypes.Height{RevisionNumber: 0, RevisionHeight: 1}
trustPeriod, err := ccvtypes.CalculateTrustPeriod(genesisState.Params.UnbondingPeriod, ccvprovidertypes.DefaultTrustingPeriodFraction)
genesisState.Provider.ClientState.LatestHeight = ibcclienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}
trustPeriod, err := types.CalculateTrustPeriod(genesisState.Params.UnbondingPeriod, ccvprovidertypes.DefaultTrustingPeriodFraction)
if err != nil {
panic("provider client trusting period error")
}
Expand All @@ -26,7 +27,7 @@ func CreateMinimalConsumerTestGenesis() *ccvtypes.ConsumerGenesisState {
genesisState.Provider.ClientState.MaxClockDrift = ccvprovidertypes.DefaultMaxClockDrift
genesisState.Provider.ConsensusState = &ibctmtypes.ConsensusState{
Timestamp: time.Now().UTC(),
Root: types.MerkleRoot{Hash: []byte("dummy")},
Root: ibccommitmenttypes.MerkleRoot{Hash: []byte("dummy")},
}

return genesisState
Expand Down

0 comments on commit 0344628

Please sign in to comment.