don't create localhost (#6974)
This commit is contained in:
parent
3322e269a1
commit
6ebc476474
|
@ -9,8 +9,6 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/simapp"
|
"github.com/cosmos/cosmos-sdk/simapp"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClientTestSuite struct {
|
type ClientTestSuite struct {
|
||||||
|
@ -34,6 +32,7 @@ func TestClientTestSuite(t *testing.T) {
|
||||||
suite.Run(t, new(ClientTestSuite))
|
suite.Run(t, new(ClientTestSuite))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: uncomment once simapp is switched to proto
|
||||||
func (suite *ClientTestSuite) TestBeginBlocker() {
|
func (suite *ClientTestSuite) TestBeginBlocker() {
|
||||||
prevHeight := suite.ctx.BlockHeight()
|
prevHeight := suite.ctx.BlockHeight()
|
||||||
|
|
||||||
|
@ -55,3 +54,4 @@ func (suite *ClientTestSuite) TestBeginBlocker() {
|
||||||
prevHeight = int64(localHostClient.GetLatestHeight())
|
prevHeight = int64(localHostClient.GetLatestHeight())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -16,6 +16,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("invalid client state")
|
panic("invalid client state")
|
||||||
}
|
}
|
||||||
|
|
||||||
k.SetClientState(ctx, client.ClientID, cs)
|
k.SetClientState(ctx, client.ClientID, cs)
|
||||||
k.SetClientType(ctx, client.ClientID, cs.ClientType())
|
k.SetClientType(ctx, client.ClientID, cs.ClientType())
|
||||||
}
|
}
|
||||||
|
@ -55,6 +56,6 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
|
||||||
return types.GenesisState{
|
return types.GenesisState{
|
||||||
Clients: k.GetAllGenesisClients(ctx),
|
Clients: k.GetAllGenesisClients(ctx),
|
||||||
ClientsConsensus: k.GetAllConsensusStates(ctx),
|
ClientsConsensus: k.GetAllConsensusStates(ctx),
|
||||||
CreateLocalhost: true,
|
CreateLocalhost: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
|
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
|
||||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||||
localhosttypes "github.com/cosmos/cosmos-sdk/x/ibc/09-localhost/types"
|
|
||||||
|
|
||||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||||
)
|
)
|
||||||
|
@ -232,6 +231,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func (suite *KeeperTestSuite) TestUpdateClientLocalhost() {
|
func (suite *KeeperTestSuite) TestUpdateClientLocalhost() {
|
||||||
var localhostClient exported.ClientState = localhosttypes.NewClientState(suite.header.ChainID, suite.ctx.BlockHeight())
|
var localhostClient exported.ClientState = localhosttypes.NewClientState(suite.header.ChainID, suite.ctx.BlockHeight())
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ func (suite *KeeperTestSuite) TestUpdateClientLocalhost() {
|
||||||
updatedClientState, err := suite.keeper.UpdateClient(suite.ctx, exported.ClientTypeLocalHost, nil)
|
updatedClientState, err := suite.keeper.UpdateClient(suite.ctx, exported.ClientTypeLocalHost, nil)
|
||||||
suite.Require().NoError(err, err)
|
suite.Require().NoError(err, err)
|
||||||
suite.Require().Equal(localhostClient.GetLatestHeight()+1, updatedClientState.GetLatestHeight())
|
suite.Require().Equal(localhostClient.GetLatestHeight()+1, updatedClientState.GetLatestHeight())
|
||||||
}
|
}*/
|
||||||
|
|
||||||
func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||||
altPrivVal := tmtypes.NewMockPV()
|
altPrivVal := tmtypes.NewMockPV()
|
||||||
|
|
|
@ -131,17 +131,17 @@ func (k Keeper) GetAllConsensusStates(ctx sdk.Context) types.ClientsConsensusSta
|
||||||
mapClientIDToConsStateIdx := make(map[string]int)
|
mapClientIDToConsStateIdx := make(map[string]int)
|
||||||
|
|
||||||
k.IterateConsensusStates(ctx, func(clientID string, cs exported.ConsensusState) bool {
|
k.IterateConsensusStates(ctx, func(clientID string, cs exported.ConsensusState) bool {
|
||||||
anyClientState := types.MustPackConsensusState(cs)
|
anyConsensusState := types.MustPackConsensusState(cs)
|
||||||
|
|
||||||
idx, ok := mapClientIDToConsStateIdx[clientID]
|
idx, ok := mapClientIDToConsStateIdx[clientID]
|
||||||
if ok {
|
if ok {
|
||||||
clientConsStates[idx].ConsensusStates = append(clientConsStates[idx].ConsensusStates, anyClientState)
|
clientConsStates[idx].ConsensusStates = append(clientConsStates[idx].ConsensusStates, anyConsensusState)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
clientConsState := types.ClientConsensusStates{
|
clientConsState := types.ClientConsensusStates{
|
||||||
ClientID: clientID,
|
ClientID: clientID,
|
||||||
ConsensusStates: []*codectypes.Any{anyClientState},
|
ConsensusStates: []*codectypes.Any{anyConsensusState},
|
||||||
}
|
}
|
||||||
|
|
||||||
clientConsStates = append(clientConsStates, clientConsState)
|
clientConsStates = append(clientConsStates, clientConsState)
|
||||||
|
|
|
@ -133,9 +133,10 @@ func (suite KeeperTestSuite) TestGetAllClients() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add localhost client
|
// add localhost client
|
||||||
localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.ClientTypeLocalHost)
|
// TODO: uncomment after simapp is migrated to proto
|
||||||
suite.Require().True(found)
|
// localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.ClientTypeLocalHost)
|
||||||
expClients = append(expClients, localHostClient)
|
// suite.Require().True(found)
|
||||||
|
// expClients = append(expClients, localHostClient)
|
||||||
|
|
||||||
clients := suite.keeper.GetAllClients(suite.ctx)
|
clients := suite.keeper.GetAllClients(suite.ctx)
|
||||||
suite.Require().Len(clients, len(expClients))
|
suite.Require().Len(clients, len(expClients))
|
||||||
|
@ -160,9 +161,10 @@ func (suite KeeperTestSuite) TestGetAllGenesisClients() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add localhost client
|
// add localhost client
|
||||||
localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.ClientTypeLocalHost)
|
// TODO: uncomment after simapp is migrated to proto
|
||||||
suite.Require().True(found)
|
// localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.ClientTypeLocalHost)
|
||||||
expGenClients = append(expGenClients, types.NewGenesisClientState(exported.ClientTypeLocalHost, localHostClient))
|
// suite.Require().True(found)
|
||||||
|
// expGenClients = append(expGenClients, types.NewGenesisClientState(exported.ClientTypeLocalHost, localHostClient))
|
||||||
|
|
||||||
genClients := suite.keeper.GetAllGenesisClients(suite.ctx)
|
genClients := suite.keeper.GetAllGenesisClients(suite.ctx)
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ func DefaultGenesisState() GenesisState {
|
||||||
return GenesisState{
|
return GenesisState{
|
||||||
Clients: []GenesisClientState{},
|
Clients: []GenesisClientState{},
|
||||||
ClientsConsensus: ClientsConsensusStates{},
|
ClientsConsensus: ClientsConsensusStates{},
|
||||||
CreateLocalhost: true,
|
CreateLocalhost: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ import (
|
||||||
clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
|
clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// REMOVE: once simapp uses proto
|
||||||
|
func RegisterCodec(cdc *codec.Codec) {
|
||||||
|
cdc.RegisterConcrete(ClientState{}, "ibc/client/localhost/ClientState", nil)
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterInterfaces register the ibc interfaces submodule implementations to protobuf
|
// RegisterInterfaces register the ibc interfaces submodule implementations to protobuf
|
||||||
// Any.
|
// Any.
|
||||||
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
func RegisterCodec(cdc *codec.Codec) {
|
func RegisterCodec(cdc *codec.Codec) {
|
||||||
clienttypes.RegisterCodec(cdc)
|
clienttypes.RegisterCodec(cdc)
|
||||||
ibctmtypes.RegisterCodec(cdc)
|
ibctmtypes.RegisterCodec(cdc)
|
||||||
|
localhosttypes.RegisterCodec(cdc)
|
||||||
commitmenttypes.RegisterCodec(cdc)
|
commitmenttypes.RegisterCodec(cdc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue