don't create localhost (#6974)

This commit is contained in:
colin axnér
2020-08-07 12:42:12 +00:00
committed by GitHub
parent 3322e269a1
commit 6ebc476474
8 changed files with 24 additions and 15 deletions
+2 -2
View File
@@ -9,8 +9,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simapp"
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 {
@@ -34,6 +32,7 @@ func TestClientTestSuite(t *testing.T) {
suite.Run(t, new(ClientTestSuite))
}
/* TODO: uncomment once simapp is switched to proto
func (suite *ClientTestSuite) TestBeginBlocker() {
prevHeight := suite.ctx.BlockHeight()
@@ -55,3 +54,4 @@ func (suite *ClientTestSuite) TestBeginBlocker() {
prevHeight = int64(localHostClient.GetLatestHeight())
}
}
*/
+2 -1
View File
@@ -16,6 +16,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
if !ok {
panic("invalid client state")
}
k.SetClientState(ctx, client.ClientID, cs)
k.SetClientType(ctx, client.ClientID, cs.ClientType())
}
@@ -55,6 +56,6 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
return types.GenesisState{
Clients: k.GetAllGenesisClients(ctx),
ClientsConsensus: k.GetAllConsensusStates(ctx),
CreateLocalhost: true,
CreateLocalhost: false,
}
}
+2 -2
View File
@@ -9,7 +9,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
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"
)
@@ -232,6 +231,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
}
}
/*
func (suite *KeeperTestSuite) TestUpdateClientLocalhost() {
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)
suite.Require().NoError(err, err)
suite.Require().Equal(localhostClient.GetLatestHeight()+1, updatedClientState.GetLatestHeight())
}
}*/
func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
altPrivVal := tmtypes.NewMockPV()
+3 -3
View File
@@ -131,17 +131,17 @@ func (k Keeper) GetAllConsensusStates(ctx sdk.Context) types.ClientsConsensusSta
mapClientIDToConsStateIdx := make(map[string]int)
k.IterateConsensusStates(ctx, func(clientID string, cs exported.ConsensusState) bool {
anyClientState := types.MustPackConsensusState(cs)
anyConsensusState := types.MustPackConsensusState(cs)
idx, ok := mapClientIDToConsStateIdx[clientID]
if ok {
clientConsStates[idx].ConsensusStates = append(clientConsStates[idx].ConsensusStates, anyClientState)
clientConsStates[idx].ConsensusStates = append(clientConsStates[idx].ConsensusStates, anyConsensusState)
return false
}
clientConsState := types.ClientConsensusStates{
ClientID: clientID,
ConsensusStates: []*codectypes.Any{anyClientState},
ConsensusStates: []*codectypes.Any{anyConsensusState},
}
clientConsStates = append(clientConsStates, clientConsState)
+8 -6
View File
@@ -133,9 +133,10 @@ func (suite KeeperTestSuite) TestGetAllClients() {
}
// add localhost client
localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.ClientTypeLocalHost)
suite.Require().True(found)
expClients = append(expClients, localHostClient)
// TODO: uncomment after simapp is migrated to proto
// localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.ClientTypeLocalHost)
// suite.Require().True(found)
// expClients = append(expClients, localHostClient)
clients := suite.keeper.GetAllClients(suite.ctx)
suite.Require().Len(clients, len(expClients))
@@ -160,9 +161,10 @@ func (suite KeeperTestSuite) TestGetAllGenesisClients() {
}
// add localhost client
localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.ClientTypeLocalHost)
suite.Require().True(found)
expGenClients = append(expGenClients, types.NewGenesisClientState(exported.ClientTypeLocalHost, localHostClient))
// TODO: uncomment after simapp is migrated to proto
// localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.ClientTypeLocalHost)
// suite.Require().True(found)
// expGenClients = append(expGenClients, types.NewGenesisClientState(exported.ClientTypeLocalHost, localHostClient))
genClients := suite.keeper.GetAllGenesisClients(suite.ctx)
+1 -1
View File
@@ -118,7 +118,7 @@ func DefaultGenesisState() GenesisState {
return GenesisState{
Clients: []GenesisClientState{},
ClientsConsensus: ClientsConsensusStates{},
CreateLocalhost: true,
CreateLocalhost: false,
}
}
+5
View File
@@ -7,6 +7,11 @@ import (
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
// Any.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
+1
View File
@@ -16,6 +16,7 @@ import (
func RegisterCodec(cdc *codec.Codec) {
clienttypes.RegisterCodec(cdc)
ibctmtypes.RegisterCodec(cdc)
localhosttypes.RegisterCodec(cdc)
commitmenttypes.RegisterCodec(cdc)
}