remove client type from 02-client (#7336)
* remove client type struct Remove the client type struct, remove ClientType interface function from Header and Misbehaviour. ClientState and ConsensusState return the ClientType as a string. All uses of client type in testing are now pointing at the testing package so changing the location of the client type const will be painless. * update godoc and add back client type interface func Add godoc to client type constant for solo machine, tendermint, and localhost as per @fedekunze review suggestion. Add back the ClientType interface function for misbehaviour and header for solo machine and tendermint and add back the one liner unit tests as per @AdityaSripal suggestion. * remove client state from return remove client state from the return of CreateClient, UpdateClient, and CheckMisbehaviourAndUpdateState as well as update tests to reflect this change. * fix build error introduced by latest merge Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
83f2c75f3d
commit
9e7f504da9
@ -9,7 +9,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
exported "github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
@ -32,7 +31,7 @@ func (suite *TransferTestSuite) SetupTest() {
|
||||
// constructs a send from chainA to chainB on the established channel/connection
|
||||
// and sends the same coin back from chainB to chainA.
|
||||
func (suite *TransferTestSuite) TestHandleMsgTransfer() {
|
||||
clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED)
|
||||
originalBalance := suite.chainA.App.BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom)
|
||||
timeoutHeight := clienttypes.NewHeight(0, 110)
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
@ -29,28 +28,28 @@ func (suite *KeeperTestSuite) TestSendTransfer() {
|
||||
}{
|
||||
{"successful transfer from source chain",
|
||||
func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED)
|
||||
amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))
|
||||
}, true, true},
|
||||
{"successful transfer with coin from counterparty chain",
|
||||
func() {
|
||||
// send coin from chainA back to chainB
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED)
|
||||
amount = types.GetTransferCoin(channelA.PortID, channelA.ID, sdk.DefaultBondDenom, 100)
|
||||
}, false, true},
|
||||
{"source channel not found",
|
||||
func() {
|
||||
// channel references wrong ID
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED)
|
||||
channelA.ID = ibctesting.InvalidID
|
||||
amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))
|
||||
}, true, false},
|
||||
{"next seq send not found",
|
||||
func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA = connA.NextTestChannel(ibctesting.TransferPort)
|
||||
channelB = connB.NextTestChannel(ibctesting.TransferPort)
|
||||
// manually create channel so next seq send is never set
|
||||
@ -67,20 +66,20 @@ func (suite *KeeperTestSuite) TestSendTransfer() {
|
||||
// - source chain
|
||||
{"send coin failed",
|
||||
func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED)
|
||||
amount = sdk.NewCoin("randomdenom", sdk.NewInt(100))
|
||||
}, true, false},
|
||||
// - receiving chain
|
||||
{"send from module account failed",
|
||||
func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED)
|
||||
amount = types.GetTransferCoin(channelA.PortID, channelA.ID, " randomdenom", 100)
|
||||
}, false, false},
|
||||
{"channel capability not found",
|
||||
func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED)
|
||||
cap := suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
|
||||
@ -178,7 +177,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED)
|
||||
receiver = suite.chainB.SenderAccount.GetAddress().String() // must be explicitly changed in malleate
|
||||
|
||||
@ -366,7 +365,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED)
|
||||
amount = sdk.NewInt(100) // must be explicitly changed
|
||||
sender = suite.chainA.SenderAccount.GetAddress().String()
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
@ -55,7 +54,7 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() {
|
||||
suite.Run(tc.name, func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
_, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
testChannel = connA.NextTestChannel(ibctesting.TransferPort)
|
||||
counterparty := channeltypes.NewCounterparty(testChannel.PortID, testChannel.ID)
|
||||
channel = &channeltypes.Channel{
|
||||
@ -143,7 +142,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() {
|
||||
suite.Run(tc.name, func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
_, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
testChannel = connA.NextTestChannel(ibctesting.TransferPort)
|
||||
counterparty := channeltypes.NewCounterparty(testChannel.PortID, testChannel.ID)
|
||||
channel = &channeltypes.Channel{
|
||||
@ -209,7 +208,7 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() {
|
||||
suite.Run(tc.name, func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
_, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
testChannel = connA.NextTestChannel(ibctesting.TransferPort)
|
||||
counterpartyVersion = types.Version
|
||||
|
||||
|
||||
@ -8,14 +8,13 @@ import (
|
||||
|
||||
// BeginBlocker updates an existing localhost client with the latest block height.
|
||||
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
|
||||
_, found := k.GetClientState(ctx, exported.ClientTypeLocalHost)
|
||||
_, found := k.GetClientState(ctx, exported.Localhost)
|
||||
if !found {
|
||||
return
|
||||
}
|
||||
|
||||
// update the localhost client with the latest block height
|
||||
_, err := k.UpdateClient(ctx, exported.ClientTypeLocalHost, nil)
|
||||
if err != nil {
|
||||
if err := k.UpdateClient(ctx, exported.Localhost, nil); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ func TestClientTestSuite(t *testing.T) {
|
||||
func (suite *ClientTestSuite) TestBeginBlocker() {
|
||||
prevHeight := types.GetSelfHeight(suite.chainA.GetContext())
|
||||
|
||||
localHostClient := suite.chainA.GetClientState(exported.ClientTypeLocalHost)
|
||||
localHostClient := suite.chainA.GetClientState(exported.Localhost)
|
||||
suite.Require().Equal(prevHeight, localHostClient.GetLatestHeight())
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
@ -45,7 +45,7 @@ func (suite *ClientTestSuite) TestBeginBlocker() {
|
||||
client.BeginBlocker(suite.chainA.GetContext(), suite.chainA.App.IBCKeeper.ClientKeeper)
|
||||
}, "BeginBlocker shouldn't panic")
|
||||
|
||||
localHostClient = suite.chainA.GetClientState(exported.ClientTypeLocalHost)
|
||||
localHostClient = suite.chainA.GetClientState(exported.Localhost)
|
||||
suite.Require().Equal(prevHeight.Increment(), localHostClient.GetLatestHeight())
|
||||
prevHeight = localHostClient.GetLatestHeight().(types.Height)
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
|
||||
}
|
||||
|
||||
k.SetClientState(ctx, client.ClientId, cs)
|
||||
k.SetClientType(ctx, client.ClientId, cs.ClientType())
|
||||
}
|
||||
|
||||
for _, cs := range gs.ClientsConsensus {
|
||||
@ -40,7 +39,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
|
||||
|
||||
// NOTE: return if the localhost client was already imported. The chain-id and
|
||||
// block height will be overwriten to the correct values during BeginBlock.
|
||||
if _, found := k.GetClientState(ctx, exported.ClientTypeLocalHost); found {
|
||||
if _, found := k.GetClientState(ctx, exported.Localhost); found {
|
||||
return
|
||||
}
|
||||
|
||||
@ -50,8 +49,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
|
||||
ctx.ChainID(), types.NewHeight(epoch, uint64(ctx.BlockHeight())),
|
||||
)
|
||||
|
||||
_, err := k.CreateClient(ctx, exported.ClientTypeLocalHost, clientState, nil)
|
||||
if err != nil {
|
||||
if err := k.CreateClient(ctx, exported.Localhost, clientState, nil); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@ -22,8 +20,7 @@ func HandleMsgCreateClient(ctx sdk.Context, k keeper.Keeper, msg *types.MsgCreat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = k.CreateClient(ctx, msg.ClientId, clientState, consensusState)
|
||||
if err != nil {
|
||||
if err = k.CreateClient(ctx, msg.ClientId, clientState, consensusState); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -31,7 +28,7 @@ func HandleMsgCreateClient(ctx sdk.Context, k keeper.Keeper, msg *types.MsgCreat
|
||||
sdk.NewEvent(
|
||||
types.EventTypeCreateClient,
|
||||
sdk.NewAttribute(types.AttributeKeyClientID, msg.ClientId),
|
||||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType().String()),
|
||||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()),
|
||||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, clientState.GetLatestHeight().String()),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
@ -52,8 +49,7 @@ func HandleMsgUpdateClient(ctx sdk.Context, k keeper.Keeper, msg *types.MsgUpdat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = k.UpdateClient(ctx, msg.ClientId, header)
|
||||
if err != nil {
|
||||
if err = k.UpdateClient(ctx, msg.ClientId, header); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -85,8 +81,8 @@ func HandleMsgSubmitMisbehaviour(ctx sdk.Context, k keeper.Keeper, msg *types.Ms
|
||||
sdk.NewEvent(
|
||||
types.EventTypeSubmitMisbehaviour,
|
||||
sdk.NewAttribute(types.AttributeKeyClientID, msg.ClientId),
|
||||
sdk.NewAttribute(types.AttributeKeyClientType, misbehaviour.ClientType().String()),
|
||||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, fmt.Sprintf("%d", misbehaviour.GetHeight())),
|
||||
sdk.NewAttribute(types.AttributeKeyClientType, misbehaviour.ClientType()),
|
||||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, misbehaviour.GetHeight().String()),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
@ -24,7 +23,7 @@ func (suite *ClientTestSuite) TestNewClientUpdateProposalHandler() {
|
||||
}{
|
||||
{
|
||||
"valid update client proposal", func() {
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientState := suite.chainA.GetClientState(clientA)
|
||||
|
||||
tmClientState, ok := clientState.(*ibctmtypes.ClientState)
|
||||
|
||||
@ -15,15 +15,10 @@ import (
|
||||
// CONTRACT: ClientState was constructed correctly from given initial consensusState
|
||||
func (k Keeper) CreateClient(
|
||||
ctx sdk.Context, clientID string, clientState exported.ClientState, consensusState exported.ConsensusState,
|
||||
) (exported.ClientState, error) {
|
||||
) error {
|
||||
_, found := k.GetClientState(ctx, clientID)
|
||||
if found {
|
||||
return nil, sdkerrors.Wrapf(types.ErrClientExists, "cannot create client with ID %s", clientID)
|
||||
}
|
||||
|
||||
_, found = k.GetClientType(ctx, clientID)
|
||||
if found {
|
||||
panic(fmt.Sprintf("client type is already defined for client %s", clientID))
|
||||
return sdkerrors.Wrapf(types.ErrClientExists, "cannot create client with ID %s", clientID)
|
||||
}
|
||||
|
||||
if consensusState != nil {
|
||||
@ -31,33 +26,21 @@ func (k Keeper) CreateClient(
|
||||
}
|
||||
|
||||
k.SetClientState(ctx, clientID, clientState)
|
||||
k.SetClientType(ctx, clientID, clientState.ClientType())
|
||||
k.Logger(ctx).Info(fmt.Sprintf("client %s created at height %d", clientID, clientState.GetLatestHeight()))
|
||||
|
||||
return clientState, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateClient updates the consensus state and the state root from a provided header.
|
||||
func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.Header) (exported.ClientState, error) {
|
||||
clientType, found := k.GetClientType(ctx, clientID)
|
||||
if !found {
|
||||
return nil, sdkerrors.Wrapf(types.ErrClientTypeNotFound, "cannot update client with ID %s", clientID)
|
||||
}
|
||||
|
||||
// check that the header consensus matches the client one
|
||||
// NOTE: not checked for localhost client
|
||||
if header != nil && clientType != exported.Localhost && header.ClientType() != clientType {
|
||||
return nil, sdkerrors.Wrapf(types.ErrInvalidHeader, "header client type (%s) does not match expected client type (%s) for client with ID %s", header.ClientType(), clientType, clientID)
|
||||
}
|
||||
|
||||
func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.Header) error {
|
||||
clientState, found := k.GetClientState(ctx, clientID)
|
||||
if !found {
|
||||
return nil, sdkerrors.Wrapf(types.ErrClientNotFound, "cannot update client with ID %s", clientID)
|
||||
return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot update client with ID %s", clientID)
|
||||
}
|
||||
|
||||
// prevent update if the client is frozen before or at header height
|
||||
if clientState.IsFrozen() && clientState.GetFrozenHeight().LTE(header.GetHeight()) {
|
||||
return nil, sdkerrors.Wrapf(types.ErrClientFrozen, "cannot update client with ID %s", clientID)
|
||||
return sdkerrors.Wrapf(types.ErrClientFrozen, "cannot update client with ID %s", clientID)
|
||||
}
|
||||
|
||||
var (
|
||||
@ -69,13 +52,13 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H
|
||||
clientState, consensusState, err = clientState.CheckHeaderAndUpdateState(ctx, k.cdc, k.ClientStore(ctx, clientID), header)
|
||||
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrapf(err, "cannot update client with ID %s", clientID)
|
||||
return sdkerrors.Wrapf(err, "cannot update client with ID %s", clientID)
|
||||
}
|
||||
|
||||
k.SetClientState(ctx, clientID, clientState)
|
||||
|
||||
// we don't set consensus state for localhost client
|
||||
if header != nil && clientType != exported.Localhost {
|
||||
if header != nil && clientID != exported.Localhost {
|
||||
k.SetClientConsensusState(ctx, clientID, header.GetHeight(), consensusState)
|
||||
consensusHeight = header.GetHeight()
|
||||
} else {
|
||||
@ -89,12 +72,12 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H
|
||||
sdk.NewEvent(
|
||||
types.EventTypeUpdateClient,
|
||||
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
|
||||
sdk.NewAttribute(types.AttributeKeyClientType, clientType.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()),
|
||||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeight.String()),
|
||||
),
|
||||
)
|
||||
|
||||
return clientState, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckMisbehaviourAndUpdateState checks for client misbehaviour and freezes the
|
||||
|
||||
@ -15,13 +15,7 @@ import (
|
||||
ibctestingmock "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock"
|
||||
)
|
||||
|
||||
const (
|
||||
invalidClientType exported.ClientType = 0
|
||||
)
|
||||
|
||||
func (suite *KeeperTestSuite) TestCreateClient() {
|
||||
suite.keeper.SetClientType(suite.ctx, testClientID2, exported.Tendermint)
|
||||
|
||||
cases := []struct {
|
||||
msg string
|
||||
clientID string
|
||||
@ -30,7 +24,6 @@ func (suite *KeeperTestSuite) TestCreateClient() {
|
||||
}{
|
||||
{"success", testClientID, true, false},
|
||||
{"client ID exists", testClientID, false, false},
|
||||
{"client type exists", testClientID2, false, true},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
@ -47,7 +40,7 @@ func (suite *KeeperTestSuite) TestCreateClient() {
|
||||
suite.Require().NotNil(clientState, "valid test case %d failed: %s", i, tc.msg)
|
||||
}
|
||||
// If we were able to NewClientState clientstate successfully, try persisting it to state
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, tc.clientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, tc.clientID, clientState, suite.consensusState)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err, "valid test case %d failed: %s", i, tc.msg)
|
||||
@ -86,7 +79,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
}{
|
||||
{"valid update", func() error {
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
// store intermediate consensus state to check that trustedHeight does not need to be highest consensus state before header height
|
||||
incrementedClientHeight := testClientHeight.Increment()
|
||||
@ -104,7 +97,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
}, true},
|
||||
{"valid past update", func() error {
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
height1 := types.NewHeight(0, 1)
|
||||
@ -130,19 +123,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
updateHeader = createPastUpdateFn(suite)
|
||||
return nil
|
||||
}, true},
|
||||
{"client type not found", func() error {
|
||||
updateHeader = createFutureUpdateFn(suite)
|
||||
|
||||
return nil
|
||||
}, false},
|
||||
{"client type and header type mismatch", func() error {
|
||||
suite.keeper.SetClientType(suite.ctx, testClientID, invalidClientType)
|
||||
updateHeader = createFutureUpdateFn(suite)
|
||||
|
||||
return nil
|
||||
}, false},
|
||||
{"client state not found", func() error {
|
||||
suite.keeper.SetClientType(suite.ctx, testClientID, exported.Tendermint)
|
||||
updateHeader = createFutureUpdateFn(suite)
|
||||
|
||||
return nil
|
||||
@ -150,7 +131,6 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
{"consensus state not found", func() error {
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
|
||||
suite.keeper.SetClientType(suite.ctx, testClientID, exported.Tendermint)
|
||||
updateHeader = createFutureUpdateFn(suite)
|
||||
|
||||
return nil
|
||||
@ -158,7 +138,6 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
{"frozen client before update", func() error {
|
||||
clientState = &ibctmtypes.ClientState{FrozenHeight: types.NewHeight(0, 1), LatestHeight: testClientHeight}
|
||||
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
|
||||
suite.keeper.SetClientType(suite.ctx, testClientID, exported.Tendermint)
|
||||
updateHeader = createFutureUpdateFn(suite)
|
||||
|
||||
return nil
|
||||
@ -166,7 +145,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
{"valid past update before client was frozen", func() error {
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
clientState.FrozenHeight = types.NewHeight(0, testClientHeight.EpochHeight-1)
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
height1 := types.NewHeight(0, 1)
|
||||
@ -185,7 +164,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
}, true},
|
||||
{"invalid header", func() error {
|
||||
clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
suite.Require().NoError(err)
|
||||
updateHeader = createPastUpdateFn(suite)
|
||||
|
||||
@ -204,7 +183,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
|
||||
suite.ctx = suite.ctx.WithBlockTime(updateHeader.Header.Time.Add(time.Minute))
|
||||
|
||||
updatedClientState, err := suite.keeper.UpdateClient(suite.ctx, testClientID, updateHeader)
|
||||
err = suite.keeper.UpdateClient(suite.ctx, testClientID, updateHeader)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err, err)
|
||||
@ -220,16 +199,14 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
|
||||
|
||||
consensusState, found := suite.keeper.GetClientConsensusState(suite.ctx, testClientID, updateHeader.GetHeight())
|
||||
suite.Require().True(found, "valid test case %d failed: %s", i, tc.name)
|
||||
// check returned client state is same as client state in store
|
||||
suite.Require().Equal(updatedClientState, newClientState, "updatedClient state not persisted correctly")
|
||||
|
||||
// Determine if clientState should be updated or not
|
||||
if updateHeader.GetHeight().GT(clientState.GetLatestHeight()) {
|
||||
// Header Height is greater than clientState latest Height, clientState should be updated with header.GetHeight()
|
||||
suite.Require().Equal(updateHeader.GetHeight(), updatedClientState.GetLatestHeight(), "clientstate height did not update")
|
||||
suite.Require().Equal(updateHeader.GetHeight(), newClientState.GetLatestHeight(), "clientstate height did not update")
|
||||
} else {
|
||||
// Update will add past consensus state, clientState should not be updated at all
|
||||
suite.Require().Equal(clientState.GetLatestHeight(), updatedClientState.GetLatestHeight(), "client state height updated for past header")
|
||||
suite.Require().Equal(clientState.GetLatestHeight(), newClientState.GetLatestHeight(), "client state height updated for past header")
|
||||
}
|
||||
|
||||
suite.Require().NoError(err, "valid test case %d failed: %s", i, tc.name)
|
||||
@ -246,9 +223,12 @@ func (suite *KeeperTestSuite) TestUpdateClientLocalhost() {
|
||||
|
||||
suite.ctx = suite.ctx.WithBlockHeight(suite.ctx.BlockHeight() + 1)
|
||||
|
||||
updatedClientState, err := suite.keeper.UpdateClient(suite.ctx, exported.ClientTypeLocalHost, nil)
|
||||
err := suite.keeper.UpdateClient(suite.ctx, exported.Localhost, nil)
|
||||
suite.Require().NoError(err, err)
|
||||
suite.Require().Equal(localhostClient.GetLatestHeight().(types.Height).Increment(), updatedClientState.GetLatestHeight())
|
||||
|
||||
clientState, found := suite.keeper.GetClientState(suite.ctx, exported.Localhost)
|
||||
suite.Require().True(found)
|
||||
suite.Require().Equal(localhostClient.GetLatestHeight().(types.Height).Increment(), clientState.GetLatestHeight())
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
@ -296,7 +276,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = bothValsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
return err
|
||||
},
|
||||
@ -313,7 +293,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = valsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
// store intermediate consensus state to check that trustedHeight does not need to be highest consensus state before header height
|
||||
intermediateConsState := &ibctmtypes.ConsensusState{
|
||||
@ -340,7 +320,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = valsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
// store trusted consensus state for Header2
|
||||
intermediateConsState := &ibctmtypes.ConsensusState{
|
||||
@ -367,7 +347,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = valsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
// intermediate consensus state at height + 3 is not created
|
||||
return err
|
||||
},
|
||||
@ -384,7 +364,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = valsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
// intermediate consensus state at height + 3 is not created
|
||||
return err
|
||||
},
|
||||
@ -407,7 +387,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
func() error {
|
||||
suite.consensusState.NextValidatorsHash = bothValsHash
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
_, err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
clientState.FrozenHeight = types.NewHeight(0, 1)
|
||||
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
|
||||
@ -429,7 +409,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
err = suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState)
|
||||
|
||||
return err
|
||||
},
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryClientState() {
|
||||
@ -111,8 +112,8 @@ func (suite *KeeperTestSuite) TestQueryClientStates() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
clientA1, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA2, _ := suite.coordinator.CreateClient(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA1, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientA2, _ := suite.coordinator.CreateClient(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
clientStateA1 := suite.chainA.GetClientState(clientA1)
|
||||
clientStateA2 := suite.chainA.GetClientState(clientA2)
|
||||
@ -141,8 +142,8 @@ func (suite *KeeperTestSuite) TestQueryClientStates() {
|
||||
tc.malleate()
|
||||
|
||||
// always add localhost which is created by default in init genesis
|
||||
localhostClientState := suite.chainA.GetClientState(exported.Localhost.String())
|
||||
identifiedLocalhost := types.NewIdentifiedClientState(exported.Localhost.String(), localhostClientState)
|
||||
localhostClientState := suite.chainA.GetClientState(exported.Localhost)
|
||||
identifiedLocalhost := types.NewIdentifiedClientState(exported.Localhost, localhostClientState)
|
||||
expClientStates = append(expClientStates, &identifiedLocalhost)
|
||||
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
@ -59,23 +59,6 @@ func (k Keeper) SetClientState(ctx sdk.Context, clientID string, clientState exp
|
||||
store.Set(host.KeyClientState(), k.MustMarshalClientState(clientState))
|
||||
}
|
||||
|
||||
// GetClientType gets the consensus type for a specific client
|
||||
func (k Keeper) GetClientType(ctx sdk.Context, clientID string) (exported.ClientType, bool) {
|
||||
store := k.ClientStore(ctx, clientID)
|
||||
bz := store.Get(host.KeyClientType())
|
||||
if bz == nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return exported.ClientType(bz[0]), true
|
||||
}
|
||||
|
||||
// SetClientType sets the specific client consensus type to the provable store
|
||||
func (k Keeper) SetClientType(ctx sdk.Context, clientID string, clientType exported.ClientType) {
|
||||
store := k.ClientStore(ctx, clientID)
|
||||
store.Set(host.KeyClientType(), []byte{byte(clientType)})
|
||||
}
|
||||
|
||||
// GetClientConsensusState gets the stored consensus state from a client at a given height.
|
||||
func (k Keeper) GetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) {
|
||||
store := k.ClientStore(ctx, clientID)
|
||||
|
||||
@ -124,14 +124,6 @@ func (suite *KeeperTestSuite) TestSetClientState() {
|
||||
suite.Require().Equal(clientState, retrievedState, "Client states are not equal")
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestSetClientType() {
|
||||
suite.keeper.SetClientType(suite.ctx, testClientID, exported.Tendermint)
|
||||
clientType, found := suite.keeper.GetClientType(suite.ctx, testClientID)
|
||||
|
||||
suite.Require().True(found, "GetClientType failed")
|
||||
suite.Require().Equal(exported.Tendermint, clientType, "ClientTypes not stored correctly")
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestSetClientConsensusState() {
|
||||
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, suite.consensusState)
|
||||
|
||||
@ -229,7 +221,7 @@ func (suite KeeperTestSuite) TestGetAllClients() {
|
||||
}
|
||||
|
||||
// add localhost client
|
||||
localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.ClientTypeLocalHost)
|
||||
localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.Localhost)
|
||||
suite.Require().True(found)
|
||||
expClients = append(expClients, localHostClient)
|
||||
|
||||
@ -256,9 +248,9 @@ func (suite KeeperTestSuite) TestGetAllGenesisClients() {
|
||||
}
|
||||
|
||||
// add localhost client
|
||||
localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.ClientTypeLocalHost)
|
||||
localHostClient, found := suite.keeper.GetClientState(suite.ctx, exported.Localhost)
|
||||
suite.Require().True(found)
|
||||
expGenClients = append(expGenClients, types.NewIdentifiedClientState(exported.ClientTypeLocalHost, localHostClient))
|
||||
expGenClients = append(expGenClients, types.NewIdentifiedClientState(exported.Localhost, localHostClient))
|
||||
|
||||
genClients := suite.keeper.GetAllGenesisClients(suite.ctx)
|
||||
|
||||
@ -323,7 +315,7 @@ func (suite KeeperTestSuite) TestConsensusStateHelpers() {
|
||||
// 2 clients in total are created on chainA. The first client is updated so it contains an initial consensus state
|
||||
// and a consensus state at the update height.
|
||||
func (suite KeeperTestSuite) TestGetAllConsensusStates() {
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
clientState := suite.chainA.GetClientState(clientA)
|
||||
expConsensusHeight0 := clientState.GetLatestHeight()
|
||||
@ -331,7 +323,7 @@ func (suite KeeperTestSuite) TestGetAllConsensusStates() {
|
||||
suite.Require().True(ok)
|
||||
|
||||
// update client to create a second consensus state
|
||||
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
clientState = suite.chainA.GetClientState(clientA)
|
||||
@ -346,7 +338,7 @@ func (suite KeeperTestSuite) TestGetAllConsensusStates() {
|
||||
}
|
||||
|
||||
// create second client on chainA
|
||||
clientA2, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA2, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientState = suite.chainA.GetClientState(clientA2)
|
||||
|
||||
expConsensusHeight2 := clientState.GetLatestHeight()
|
||||
|
||||
@ -12,12 +12,7 @@ import (
|
||||
// ClientUpdateProposal will try to update the client with the new header if and only if
|
||||
// the proposal passes. The localhost client is not allowed to be modified with a proposal.
|
||||
func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdateProposal) error {
|
||||
clientType, found := k.GetClientType(ctx, p.ClientId)
|
||||
if !found {
|
||||
return sdkerrors.Wrapf(types.ErrClientTypeNotFound, "cannot update client with ID %s", p.ClientId)
|
||||
}
|
||||
|
||||
if clientType == exported.Localhost || p.ClientId == exported.ClientTypeLocalHost {
|
||||
if p.ClientId == exported.Localhost {
|
||||
return sdkerrors.Wrap(types.ErrInvalidUpdateClientProposal, "cannot update localhost client with proposal")
|
||||
}
|
||||
|
||||
@ -46,7 +41,7 @@ func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdatePropo
|
||||
sdk.NewEvent(
|
||||
types.EventTypeUpdateClientProposal,
|
||||
sdk.NewAttribute(types.AttributeKeyClientID, p.ClientId),
|
||||
sdk.NewAttribute(types.AttributeKeyClientType, clientType.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()),
|
||||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, fmt.Sprintf("%d", header.GetHeight())),
|
||||
),
|
||||
)
|
||||
|
||||
@ -21,7 +21,7 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() {
|
||||
}{
|
||||
{
|
||||
"valid update client proposal", func() {
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientState := suite.chainA.GetClientState(clientA)
|
||||
|
||||
tmClientState, ok := clientState.(*ibctmtypes.ClientState)
|
||||
@ -46,28 +46,26 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() {
|
||||
},
|
||||
{
|
||||
"cannot update localhost", func() {
|
||||
content, err = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, exported.Localhost.String(), &ibctmtypes.Header{})
|
||||
content, err = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, exported.Localhost, &ibctmtypes.Header{})
|
||||
suite.Require().NoError(err)
|
||||
}, false,
|
||||
},
|
||||
{
|
||||
"client does not exist", func() {
|
||||
// bypass ClientType check
|
||||
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientType(suite.chainA.GetContext(), ibctesting.InvalidID, exported.Tendermint)
|
||||
content, err = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, ibctesting.InvalidID, &ibctmtypes.Header{})
|
||||
suite.Require().NoError(err)
|
||||
}, false,
|
||||
},
|
||||
{
|
||||
"cannot unpack header, header is nil", func() {
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
content = &clienttypes.ClientUpdateProposal{ibctesting.Title, ibctesting.Description, clientA, nil}
|
||||
}, false,
|
||||
},
|
||||
{
|
||||
"update fails", func() {
|
||||
header := &ibctmtypes.Header{}
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
content, err = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, clientA, header)
|
||||
suite.Require().NoError(err)
|
||||
}, false,
|
||||
|
||||
@ -13,7 +13,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
func TestDecodeStore(t *testing.T) {
|
||||
@ -38,7 +38,7 @@ func TestDecodeStore(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Key: host.FullKeyClientPath(clientID, host.KeyClientType()),
|
||||
Value: []byte(exported.Tendermint.String()),
|
||||
Value: []byte(ibctesting.Tendermint),
|
||||
},
|
||||
{
|
||||
Key: host.FullKeyClientPath(clientID, host.KeyConsensusState(height)),
|
||||
@ -55,7 +55,7 @@ func TestDecodeStore(t *testing.T) {
|
||||
expectedLog string
|
||||
}{
|
||||
{"ClientState", fmt.Sprintf("ClientState A: %v\nClientState B: %v", clientState, clientState)},
|
||||
{"client type", fmt.Sprintf("Client type A: %s\nClient type B: %s", exported.Tendermint, exported.Tendermint)},
|
||||
{"client type", fmt.Sprintf("Client type A: %s\nClient type B: %s", ibctesting.Tendermint, ibctesting.Tendermint)},
|
||||
{"ConsensusState", fmt.Sprintf("ConsensusState A: %v\nConsensusState B: %v", consState, consState)},
|
||||
{"other", ""},
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package types_test
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
@ -23,7 +22,7 @@ func (suite *TypesTestSuite) TestMarshalConsensusStateWithHeight() {
|
||||
},
|
||||
{
|
||||
"tendermint client", func() {
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientState := suite.chainA.GetClientState(clientA)
|
||||
consensusState, ok := suite.chainA.GetConsensusState(clientA, clientState.GetLatestHeight())
|
||||
suite.Require().True(ok)
|
||||
|
||||
@ -30,7 +30,7 @@ var clientHeight = types.NewHeight(0, 10)
|
||||
func (suite *TypesTestSuite) TestMarshalGenesisState() {
|
||||
cdc := suite.chainA.App.AppCodec()
|
||||
clientA, _, _, _, _, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.ORDERED)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
genesis := client.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.IBCKeeper.ClientKeeper)
|
||||
|
||||
@ -74,7 +74,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(
|
||||
exported.ClientTypeLocalHost, localhosttypes.NewClientState("chainID", clientHeight),
|
||||
exported.Localhost, localhosttypes.NewClientState("chainID", clientHeight),
|
||||
),
|
||||
},
|
||||
[]types.ClientConsensusStates{
|
||||
@ -102,7 +102,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
"/~@$*", ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(
|
||||
exported.ClientTypeLocalHost, localhosttypes.NewClientState("chainID", clientHeight),
|
||||
exported.Localhost, localhosttypes.NewClientState("chainID", clientHeight),
|
||||
),
|
||||
},
|
||||
[]types.ClientConsensusStates{
|
||||
@ -129,7 +129,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
types.NewIdentifiedClientState(
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(exported.ClientTypeLocalHost, localhosttypes.NewClientState("chaindID", types.ZeroHeight())),
|
||||
types.NewIdentifiedClientState(exported.Localhost, localhosttypes.NewClientState("chaindID", types.ZeroHeight())),
|
||||
},
|
||||
nil,
|
||||
true,
|
||||
@ -144,7 +144,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(
|
||||
exported.ClientTypeLocalHost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
),
|
||||
},
|
||||
[]types.ClientConsensusStates{
|
||||
@ -172,7 +172,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(
|
||||
exported.ClientTypeLocalHost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
),
|
||||
},
|
||||
[]types.ClientConsensusStates{
|
||||
|
||||
@ -70,7 +70,7 @@ func (msg MsgCreateClient) ValidateBasic() error {
|
||||
if err := clientState.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if clientState.ClientType() == exported.Localhost || msg.ClientId == exported.ClientTypeLocalHost {
|
||||
if clientState.ClientType() == exported.Localhost || msg.ClientId == exported.Localhost {
|
||||
return sdkerrors.Wrap(ErrInvalidClient, "localhost client can only be created on chain initialization")
|
||||
}
|
||||
consensusState, err := UnpackConsensusState(msg.ConsensusState)
|
||||
@ -146,7 +146,7 @@ func (msg MsgUpdateClient) ValidateBasic() error {
|
||||
if err := header.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
if msg.ClientId == exported.ClientTypeLocalHost {
|
||||
if msg.ClientId == exported.Localhost {
|
||||
return sdkerrors.Wrap(ErrInvalidClient, "localhost client is only updated on ABCI BeginBlock")
|
||||
}
|
||||
return host.ClientIdentifierValidator(msg.ClientId)
|
||||
|
||||
@ -315,7 +315,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() {
|
||||
{
|
||||
"unsupported - localhost",
|
||||
func() {
|
||||
msg, err = types.NewMsgUpdateClient(exported.ClientTypeLocalHost, suite.chainA.CreateTMClientHeader(), suite.chainA.SenderAccount.GetAddress())
|
||||
msg, err = types.NewMsgUpdateClient(exported.Localhost, suite.chainA.CreateTMClientHeader(), suite.chainA.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
false,
|
||||
|
||||
@ -47,7 +47,7 @@ func (suite *KeeperTestSuite) TestQueryConnection() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA := suite.chainA.GetFirstTestConnection(clientA, clientB)
|
||||
connB := suite.chainB.GetFirstTestConnection(clientB, clientA)
|
||||
|
||||
@ -111,11 +111,11 @@ func (suite *KeeperTestSuite) TestQueryConnections() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
clientA, clientB, connA0, connB0 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB, connA0, connB0 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA1, connB1, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
clientA1, clientB1, connA2, connB2 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA1, clientB1, connA2, connB2 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
counterparty1 := types.NewCounterparty(clientB, connB0.ID, suite.chainB.GetPrefix())
|
||||
counterparty2 := types.NewCounterparty(clientB, connB1.ID, suite.chainB.GetPrefix())
|
||||
@ -197,7 +197,7 @@ func (suite *KeeperTestSuite) TestQueryClientConnections() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
clientA, clientB, connA0, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB, connA0, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA1, _ := suite.coordinator.CreateConnection(suite.chainA, suite.chainB, clientA, clientB)
|
||||
expPaths = []string{connA0.ID, connA1.ID}
|
||||
suite.chainA.App.IBCKeeper.ConnectionKeeper.SetClientConnectionPaths(suite.chainA.GetContext(), clientA, expPaths)
|
||||
@ -282,7 +282,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionClientState() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
clientA, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
expClientState := suite.chainA.GetClientState(clientA)
|
||||
expIdentifiedClientState = clienttypes.NewIdentifiedClientState(clientA, expClientState)
|
||||
@ -371,7 +371,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
clientA, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
clientState := suite.chainA.GetClientState(clientA)
|
||||
expConsensusState, _ = suite.chainA.GetConsensusState(clientA, clientState.GetLatestHeight())
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
// TestConnOpenInit - chainA initializes (INIT state) a connection with
|
||||
@ -24,14 +25,14 @@ func (suite *KeeperTestSuite) TestConnOpenInit() {
|
||||
expPass bool
|
||||
}{
|
||||
{"success", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
}, true},
|
||||
{"connection already exists", func() {
|
||||
clientA, clientB, _, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB, _, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
}, false},
|
||||
{"couldn't add connection to client", func() {
|
||||
// swap client identifiers to result in client that does not exist
|
||||
clientB, clientA = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientB, clientA = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
}, false},
|
||||
}
|
||||
|
||||
@ -74,7 +75,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
expPass bool
|
||||
}{
|
||||
{"success", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
_, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -82,7 +83,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
counterpartyClient = suite.chainA.GetClientState(clientA)
|
||||
}, true},
|
||||
{"invalid counterparty client", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
_, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -97,7 +98,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientA, tmClient)
|
||||
}, false},
|
||||
{"consensus height >= latest height", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
_, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -107,7 +108,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
consensusHeight = clienttypes.GetSelfHeight(suite.chainB.GetContext())
|
||||
}, false},
|
||||
{"self consensus state not found", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
_, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -117,7 +118,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
consensusHeight = clienttypes.NewHeight(0, 1)
|
||||
}, false},
|
||||
{"counterparty versions is empty", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
_, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -127,7 +128,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
versions = nil
|
||||
}, false},
|
||||
{"counterparty versions don't have a match", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
_, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -139,14 +140,14 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
versions = []string{version}
|
||||
}, false},
|
||||
{"connection state verification failed", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
// chainA connection not created
|
||||
|
||||
// retrieve client state of chainA to pass as counterpartyClient
|
||||
counterpartyClient = suite.chainA.GetClientState(clientA)
|
||||
}, false},
|
||||
{"client state verification failed", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
_, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -159,7 +160,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
tmClient.LatestHeight = tmClient.LatestHeight.Increment()
|
||||
}, false},
|
||||
{"consensus state verification failed", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
// retrieve client state of chainA to pass as counterpartyClient
|
||||
counterpartyClient = suite.chainA.GetClientState(clientA)
|
||||
@ -178,7 +179,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
suite.Require().NoError(err)
|
||||
}, false},
|
||||
{"invalid previous connection is in TRYOPEN", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
// open init chainA
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
@ -188,7 +189,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
err = suite.coordinator.ConnOpenTry(suite.chainB, suite.chainA, connB, connA)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint)
|
||||
err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// retrieve client state of chainA to pass as counterpartyClient
|
||||
@ -196,7 +197,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
|
||||
}, false},
|
||||
{"invalid previous connection has invalid versions", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
// open init chainA
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
@ -215,7 +216,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
|
||||
suite.chainB.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainB.GetContext(), connB.ID, connection)
|
||||
|
||||
err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint)
|
||||
err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// retrieve client state of chainA to pass as counterpartyClient
|
||||
@ -283,7 +284,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
expPass bool
|
||||
}{
|
||||
{"success", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -295,7 +296,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
}, true},
|
||||
{"success from tryopen", func() {
|
||||
// chainA is in TRYOPEN, chainB is in TRYOPEN
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connB, connA, err := suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -307,15 +308,15 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
connection.State = types.TRYOPEN
|
||||
suite.chainB.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainB.GetContext(), connB.ID, connection)
|
||||
// update clientB so state change is committed
|
||||
suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint)
|
||||
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
// retrieve client state of chainB to pass as counterpartyClient
|
||||
counterpartyClient = suite.chainB.GetClientState(clientB)
|
||||
}, true},
|
||||
{"invalid counterparty client", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -333,7 +334,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
suite.Require().NoError(err)
|
||||
}, false},
|
||||
{"consensus height >= latest height", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -347,14 +348,14 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
}, false},
|
||||
{"connection not found", func() {
|
||||
// connections are never created
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
// retrieve client state of chainB to pass as counterpartyClient
|
||||
counterpartyClient = suite.chainB.GetClientState(clientB)
|
||||
}, false},
|
||||
{"connection state is not INIT", func() {
|
||||
// connection state is already OPEN on chainA
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -369,7 +370,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
}, false},
|
||||
{"connection is in INIT but the proposed version is invalid", func() {
|
||||
// chainA is in INIT, chainB is in TRYOPEN
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -383,7 +384,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
}, false},
|
||||
{"connection is in TRYOPEN but the set version in the connection is invalid", func() {
|
||||
// chainA is in TRYOPEN, chainB is in TRYOPEN
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connB, connA, err := suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -396,8 +397,8 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
suite.chainB.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainB.GetContext(), connB.ID, connection)
|
||||
|
||||
// update clientB so state change is committed
|
||||
suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
// retrieve client state of chainB to pass as counterpartyClient
|
||||
counterpartyClient = suite.chainB.GetClientState(clientB)
|
||||
@ -405,7 +406,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
version = "2.0"
|
||||
}, false},
|
||||
{"incompatible IBC versions", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -419,7 +420,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
version = "(2.0,[])"
|
||||
}, false},
|
||||
{"empty version", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -432,7 +433,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
version = ""
|
||||
}, false},
|
||||
{"feature set verification failed - unsupported feature", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -446,7 +447,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
suite.Require().NoError(err)
|
||||
}, false},
|
||||
{"self consensus state not found", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -460,7 +461,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
}, false},
|
||||
{"connection state verification failed", func() {
|
||||
// chainB connection is not in INIT
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
_, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -468,7 +469,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
counterpartyClient = suite.chainB.GetClientState(clientB)
|
||||
}, false},
|
||||
{"client state verification failed", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -484,7 +485,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
suite.Require().NoError(err)
|
||||
}, false},
|
||||
{"consensus state verification failed", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -560,7 +561,7 @@ func (suite *KeeperTestSuite) TestConnOpenConfirm() {
|
||||
expPass bool
|
||||
}{
|
||||
{"success", func() {
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -572,15 +573,15 @@ func (suite *KeeperTestSuite) TestConnOpenConfirm() {
|
||||
}, true},
|
||||
{"connection not found", func() {
|
||||
// connections are never created
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
}, false},
|
||||
{"chain B's connection state is not TRYOPEN", func() {
|
||||
// connections are OPEN
|
||||
clientA, clientB, _, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB, _, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
}, false},
|
||||
{"connection state verification failed", func() {
|
||||
// chainA is in INIT
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
@ -32,7 +31,7 @@ func TestKeeperTestSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestSetAndGetConnection() {
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA := suite.chainA.GetFirstTestConnection(clientA, clientB)
|
||||
_, existed := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetConnection(suite.chainA.GetContext(), connA.ID)
|
||||
suite.Require().False(existed)
|
||||
@ -43,7 +42,7 @@ func (suite *KeeperTestSuite) TestSetAndGetConnection() {
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestSetAndGetClientConnectionPaths() {
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
_, existed := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetClientConnectionPaths(suite.chainA.GetContext(), clientA)
|
||||
suite.False(existed)
|
||||
|
||||
@ -55,7 +54,7 @@ func (suite *KeeperTestSuite) TestSetAndGetClientConnectionPaths() {
|
||||
|
||||
// create 2 connections: A0 - B0, A1 - B1
|
||||
func (suite KeeperTestSuite) TestGetAllConnections() {
|
||||
clientA, clientB, connA0, connB0 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB, connA0, connB0 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA1, connB1 := suite.coordinator.CreateConnection(suite.chainA, suite.chainB, clientA, clientB)
|
||||
|
||||
counterpartyB0 := types.NewCounterparty(clientB, connB0.ID, suite.chainB.GetPrefix()) // connection B0
|
||||
@ -77,8 +76,8 @@ func (suite KeeperTestSuite) TestGetAllConnections() {
|
||||
// the test creates 2 clients clientA0 and clientA1. clientA0 has a single
|
||||
// connection and clientA1 has 2 connections.
|
||||
func (suite KeeperTestSuite) TestGetAllClientConnectionPaths() {
|
||||
clientA0, _, connA0, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA1, clientB1, connA1, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA0, _, connA0, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientA1, clientB1, connA1, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connA2, _ := suite.coordinator.CreateConnection(suite.chainA, suite.chainB, clientA1, clientB1)
|
||||
|
||||
expPaths := []types.ConnectionPaths{
|
||||
@ -102,7 +101,7 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() {
|
||||
expPass bool
|
||||
}{
|
||||
{"verification success", func() {
|
||||
_, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
connection = suite.chainA.GetConnection(connA)
|
||||
}, true},
|
||||
{"consensus state not found", func() {
|
||||
|
||||
@ -37,7 +37,7 @@ func (suite *KeeperTestSuite) TestVerifyClientState() {
|
||||
suite.Run(tc.msg, func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
_, clientB, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, clientB, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
counterpartyClient, clientProof := suite.chainB.QueryClientStateProof(clientB)
|
||||
proofHeight := clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()-1))
|
||||
@ -82,20 +82,20 @@ func (suite *KeeperTestSuite) TestVerifyClientConsensusState() {
|
||||
expPass bool
|
||||
}{
|
||||
{"verification success", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
}, true},
|
||||
{"client state not found", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
changeClientID = true
|
||||
}, false},
|
||||
{"consensus state not found", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
heightDiff = 5
|
||||
}, false},
|
||||
{"verification failed", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientB := connB.ClientID
|
||||
clientState := suite.chainB.GetClientState(clientB)
|
||||
|
||||
@ -169,7 +169,7 @@ func (suite *KeeperTestSuite) TestVerifyConnectionState() {
|
||||
suite.Run(tc.msg, func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
connection := suite.chainA.GetConnection(connA)
|
||||
if tc.changeClientID {
|
||||
@ -401,7 +401,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgementAbsence() {
|
||||
} else {
|
||||
// need to update height to prove absence
|
||||
suite.coordinator.CommitBlock(suite.chainA, suite.chainB)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
}
|
||||
|
||||
packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
|
||||
@ -62,7 +62,7 @@ func (suite *KeeperTestSuite) TestQueryChannel() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
// init channel
|
||||
channelA, _, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
@ -377,7 +377,7 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
clientA, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
// init channel
|
||||
channelA, _, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
@ -505,7 +505,7 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
clientA, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
// init channel
|
||||
channelA, _, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -32,7 +32,7 @@ func (suite *KeeperTestSuite) TestChanOpenInit() {
|
||||
|
||||
testCases := []testCase{
|
||||
{"success", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
features = []string{"ORDER_ORDERED", "ORDER_UNORDERED"}
|
||||
suite.chainA.CreatePortCapability(connA.NextTestChannel(ibctesting.MockPort).PortID)
|
||||
portCap = suite.chainA.GetPortCapability(connA.NextTestChannel(ibctesting.MockPort).PortID)
|
||||
@ -46,12 +46,12 @@ func (suite *KeeperTestSuite) TestChanOpenInit() {
|
||||
suite.Require().NotNil(connB)
|
||||
}, false},
|
||||
{"capability is incorrect", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
features = []string{"ORDER_ORDERED", "ORDER_UNORDERED"}
|
||||
portCap = capabilitytypes.NewCapability(3)
|
||||
}, false},
|
||||
{"connection version not negotiated", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
// modify connA versions
|
||||
conn := suite.chainA.GetConnection(connA)
|
||||
@ -69,7 +69,7 @@ func (suite *KeeperTestSuite) TestChanOpenInit() {
|
||||
portCap = suite.chainA.GetPortCapability(connA.NextTestChannel(ibctesting.MockPort).PortID)
|
||||
}, false},
|
||||
{"connection does not support ORDERED channels", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
// modify connA versions to only support UNORDERED channels
|
||||
conn := suite.chainA.GetConnection(connA)
|
||||
@ -147,14 +147,14 @@ func (suite *KeeperTestSuite) TestChanOpenTry() {
|
||||
|
||||
testCases := []testCase{
|
||||
{"success", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
|
||||
suite.chainB.CreatePortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID)
|
||||
portCap = suite.chainB.GetPortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID)
|
||||
}, true},
|
||||
{"previous channel with invalid state", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
// make previous channel have wrong ordering
|
||||
suite.coordinator.ChanOpenInit(suite.chainB, suite.chainA, connB, connA, ibctesting.MockPort, ibctesting.MockPort, types.UNORDERED)
|
||||
@ -169,7 +169,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() {
|
||||
portCap = suite.chainB.GetPortCapability(connB.FirstOrNextTestChannel(ibctesting.MockPort).PortID)
|
||||
}, false},
|
||||
{"connection is not OPEN", func() {
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
// pass capability check
|
||||
suite.chainB.CreatePortCapability(connB.FirstOrNextTestChannel(ibctesting.MockPort).PortID)
|
||||
portCap = suite.chainB.GetPortCapability(connB.FirstOrNextTestChannel(ibctesting.MockPort).PortID)
|
||||
@ -179,7 +179,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() {
|
||||
suite.Require().NoError(err)
|
||||
}, false},
|
||||
{"consensus state not found", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
|
||||
suite.chainB.CreatePortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID)
|
||||
@ -189,17 +189,17 @@ func (suite *KeeperTestSuite) TestChanOpenTry() {
|
||||
}, false},
|
||||
{"channel verification failed", func() {
|
||||
// not creating a channel on chainA will result in an invalid proof of existence
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
portCap = suite.chainB.GetPortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID)
|
||||
}, false},
|
||||
{"port capability not found", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
|
||||
portCap = capabilitytypes.NewCapability(3)
|
||||
}, false},
|
||||
{"connection version not negotiated", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
|
||||
// modify connB versions
|
||||
@ -217,7 +217,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() {
|
||||
portCap = suite.chainB.GetPortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID)
|
||||
}, false},
|
||||
{"connection does not support ORDERED channels", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
|
||||
// modify connA versions to only support UNORDERED channels
|
||||
@ -285,7 +285,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() {
|
||||
|
||||
testCases := []testCase{
|
||||
{"success", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -302,7 +302,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() {
|
||||
channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, false},
|
||||
{"connection not found", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -317,7 +317,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), channelA.PortID, channelA.ID, channel)
|
||||
}, false},
|
||||
{"connection is not OPEN", func() {
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
var err error
|
||||
connA, connB, err = suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
@ -331,7 +331,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() {
|
||||
channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, false},
|
||||
{"consensus state not found", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -344,7 +344,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() {
|
||||
}, false},
|
||||
{"channel verification failed", func() {
|
||||
// chainB is INIT, chainA in TRYOPEN
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelB, channelA, err := suite.coordinator.ChanOpenInit(suite.chainB, suite.chainA, connB, connA, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -354,7 +354,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() {
|
||||
channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, false},
|
||||
{"channel capability not found", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -404,7 +404,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() {
|
||||
)
|
||||
testCases := []testCase{
|
||||
{"success", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -424,7 +424,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() {
|
||||
channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID)
|
||||
}, false},
|
||||
{"connection not found", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -442,7 +442,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() {
|
||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainB.GetContext(), channelB.PortID, channelB.ID, channel)
|
||||
}, false},
|
||||
{"connection is not OPEN", func() {
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
var err error
|
||||
connA, connB, err = suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA)
|
||||
@ -452,7 +452,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() {
|
||||
channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID)
|
||||
}, false},
|
||||
{"consensus state not found", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -468,7 +468,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() {
|
||||
}, false},
|
||||
{"channel verification failed", func() {
|
||||
// chainA is INIT, chainB in TRYOPEN
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -478,7 +478,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() {
|
||||
channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID)
|
||||
}, false},
|
||||
{"channel capability not found", func() {
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -565,7 +565,7 @@ func (suite *KeeperTestSuite) TestChanCloseInit() {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), channelA.PortID, channelA.ID, channel)
|
||||
}, false},
|
||||
{"connection is not OPEN", func() {
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
var err error
|
||||
connA, connB, err = suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
@ -654,7 +654,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() {
|
||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainB.GetContext(), channelB.PortID, channelB.ID, channel)
|
||||
}, false},
|
||||
{"connection is not OPEN", func() {
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
var err error
|
||||
connB, connA, err = suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA)
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
@ -37,7 +36,7 @@ func (suite *KeeperTestSuite) SetupTest() {
|
||||
// and existence of a channel in INIT on chainA.
|
||||
func (suite *KeeperTestSuite) TestSetChannel() {
|
||||
// create client and connections on both chains
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
|
||||
// check for channel to be created on chainB
|
||||
channelA := connA.NextTestChannel(ibctesting.MockPort)
|
||||
|
||||
@ -129,7 +129,7 @@ func (suite *KeeperTestSuite) TestSendPacket() {
|
||||
channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, false},
|
||||
{"next sequence send not found", func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA := connA.NextTestChannel(ibctesting.TransferPort)
|
||||
channelB := connB.NextTestChannel(ibctesting.TransferPort)
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp)
|
||||
@ -257,7 +257,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() {
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp)
|
||||
}, false},
|
||||
{"connection not OPEN", func() {
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
// connection on chainB is in INIT
|
||||
connB, connA, err := suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA)
|
||||
suite.Require().NoError(err)
|
||||
@ -290,7 +290,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() {
|
||||
suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
|
||||
}, false},
|
||||
{"next receive sequence is not found", func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA := connA.NextTestChannel(ibctesting.TransferPort)
|
||||
channelB := connB.NextTestChannel(ibctesting.TransferPort)
|
||||
|
||||
@ -371,7 +371,7 @@ func (suite *KeeperTestSuite) TestReceiveExecuted() {
|
||||
suite.Require().NoError(err)
|
||||
}, false},
|
||||
{"next sequence receive not found", func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA := connA.NextTestChannel(ibctesting.TransferPort)
|
||||
channelB := connB.NextTestChannel(ibctesting.TransferPort)
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp)
|
||||
@ -489,7 +489,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp)
|
||||
}, false},
|
||||
{"connection not OPEN", func() {
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
// connection on chainA is in INIT
|
||||
connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB)
|
||||
suite.Require().NoError(err)
|
||||
@ -518,7 +518,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
}, false},
|
||||
{"next ack sequence not found", func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
channelA := connA.NextTestChannel(ibctesting.TransferPort)
|
||||
channelB := connB.NextTestChannel(ibctesting.TransferPort)
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp)
|
||||
|
||||
@ -29,7 +29,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() {
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), uint64(suite.chainB.GetContext().BlockTime().UnixNano()))
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
// need to update chainA's client representing chainB to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
}, true},
|
||||
{"success: UNORDERED", func() {
|
||||
ordered = false
|
||||
@ -38,7 +38,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() {
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), disabledTimeoutTimestamp)
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
// need to update chainA's client representing chainB to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
}, true},
|
||||
{"channel not found", func() {
|
||||
// use wrong channel naming
|
||||
@ -77,7 +77,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() {
|
||||
clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.ORDERED)
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp)
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
}, false},
|
||||
{"packet already received ", func() {
|
||||
ordered = true
|
||||
@ -86,12 +86,12 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() {
|
||||
clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.ORDERED)
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, uint64(suite.chainB.GetContext().BlockTime().UnixNano()))
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
}, false},
|
||||
{"packet hasn't been sent", func() {
|
||||
clientA, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.ORDERED)
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, uint64(suite.chainB.GetContext().BlockTime().UnixNano()))
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
}, false},
|
||||
{"next seq receive verification failed", func() {
|
||||
// set ordered to false resulting in wrong proof provided
|
||||
@ -100,7 +100,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() {
|
||||
clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.ORDERED)
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), disabledTimeoutTimestamp)
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
}, false},
|
||||
{"packet ack verification failed", func() {
|
||||
// set ordered to true resulting in wrong proof provided
|
||||
@ -109,7 +109,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() {
|
||||
clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), disabledTimeoutTimestamp)
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
}, false},
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB)
|
||||
// need to update chainA's client representing chainB to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, true},
|
||||
@ -224,7 +224,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB)
|
||||
// need to update chainA's client representing chainB to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, true},
|
||||
@ -273,7 +273,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB)
|
||||
// need to update chainA's client representing chainB to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, false},
|
||||
@ -291,7 +291,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), uint64(suite.chainB.GetContext().BlockTime().UnixNano()))
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, false},
|
||||
{"packet ack verification failed", func() {
|
||||
@ -301,7 +301,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), disabledTimeoutTimestamp)
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, false},
|
||||
{"channel capability not found", func() {
|
||||
@ -311,7 +311,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB)
|
||||
// need to update chainA's client representing chainB to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
chanCap = capabilitytypes.NewCapability(100)
|
||||
}, false},
|
||||
|
||||
@ -20,6 +20,9 @@ import (
|
||||
|
||||
var _ exported.ClientState = (*ClientState)(nil)
|
||||
|
||||
// Tendermint is used to indicate that the client uses the Tendermint Consensus Algorithm.
|
||||
const Tendermint string = "Tendermint"
|
||||
|
||||
// NewClientState creates a new ClientState instance
|
||||
func NewClientState(
|
||||
chainID string, trustLevel Fraction,
|
||||
@ -47,8 +50,8 @@ func (cs ClientState) GetChainID() string {
|
||||
}
|
||||
|
||||
// ClientType is tendermint.
|
||||
func (cs ClientState) ClientType() exported.ClientType {
|
||||
return exported.Tendermint
|
||||
func (cs ClientState) ClientType() string {
|
||||
return Tendermint
|
||||
}
|
||||
|
||||
// GetLatestHeight returns latest block height.
|
||||
|
||||
@ -548,7 +548,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// need to update chainA's client representing chainB to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
var ok bool
|
||||
clientStateI := suite.chainA.GetClientState(clientA)
|
||||
@ -639,7 +639,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// need to update chainA's client representing chainB
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
var ok bool
|
||||
clientStateI := suite.chainA.GetClientState(clientA)
|
||||
|
||||
@ -25,8 +25,8 @@ func NewConsensusState(
|
||||
}
|
||||
|
||||
// ClientType returns Tendermint
|
||||
func (ConsensusState) ClientType() exported.ClientType {
|
||||
return exported.Tendermint
|
||||
func (ConsensusState) ClientType() string {
|
||||
return Tendermint
|
||||
}
|
||||
|
||||
// GetRoot returns the commitment Root for the specific
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
)
|
||||
|
||||
func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() {
|
||||
@ -55,7 +54,7 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() {
|
||||
for i, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
suite.Require().Equal(tc.consensusState.ClientType(), exported.Tendermint)
|
||||
suite.Require().Equal(tc.consensusState.ClientType(), types.Tendermint)
|
||||
suite.Require().Equal(tc.consensusState.GetRoot(), tc.consensusState.Root)
|
||||
|
||||
if tc.expectPass {
|
||||
|
||||
@ -14,11 +14,6 @@ import (
|
||||
|
||||
var _ exported.Header = Header{}
|
||||
|
||||
// ClientType defines that the Header is a Tendermint consensus algorithm
|
||||
func (h Header) ClientType() exported.ClientType {
|
||||
return exported.Tendermint
|
||||
}
|
||||
|
||||
// ConsensusState returns the updated consensus state associated with the header
|
||||
func (h Header) ConsensusState() *ConsensusState {
|
||||
return &ConsensusState{
|
||||
@ -28,6 +23,11 @@ func (h Header) ConsensusState() *ConsensusState {
|
||||
}
|
||||
}
|
||||
|
||||
// ClientType defines that the Header is a Tendermint consensus algorithm
|
||||
func (h Header) ClientType() string {
|
||||
return Tendermint
|
||||
}
|
||||
|
||||
// GetHeight returns the current height. It returns 0 if the tendermint
|
||||
// header is nil.
|
||||
func (h Header) GetHeight() exported.Height {
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
)
|
||||
|
||||
func (suite *TendermintTestSuite) TestGetHeight() {
|
||||
@ -64,7 +63,7 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() {
|
||||
}, false},
|
||||
}
|
||||
|
||||
suite.Require().Equal(exported.Tendermint, suite.header.ClientType())
|
||||
suite.Require().Equal(types.Tendermint, suite.header.ClientType())
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
@ -31,8 +31,8 @@ func NewMisbehaviour(clientID, chainID string, header1, header2 *Header) *Misbeh
|
||||
}
|
||||
|
||||
// ClientType is Tendermint light client
|
||||
func (misbehaviour Misbehaviour) ClientType() exported.ClientType {
|
||||
return exported.Tendermint
|
||||
func (misbehaviour Misbehaviour) ClientType() string {
|
||||
return Tendermint
|
||||
}
|
||||
|
||||
// GetClientID returns the ID of the client that committed a misbehaviour.
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctestingmock "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock"
|
||||
)
|
||||
|
||||
@ -24,7 +23,7 @@ func (suite *TendermintTestSuite) TestMisbehaviour() {
|
||||
ClientId: clientID,
|
||||
}
|
||||
|
||||
suite.Require().Equal(exported.Tendermint, misbehaviour.ClientType())
|
||||
suite.Require().Equal(types.Tendermint, misbehaviour.ClientType())
|
||||
suite.Require().Equal(clientID, misbehaviour.GetClientID())
|
||||
suite.Require().Equal(height, misbehaviour.GetHeight())
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package types_test
|
||||
import (
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
@ -13,7 +12,7 @@ var (
|
||||
|
||||
// sanity checks
|
||||
func (suite *TendermintTestSuite) TestCheckProposedHeaderAndUpdateStateBasic() {
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientState := suite.chainA.GetClientState(clientA).(*types.ClientState)
|
||||
clientStore := suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), clientA)
|
||||
|
||||
@ -202,7 +201,7 @@ func (suite *TendermintTestSuite) TestCheckProposedHeaderAndUpdateState() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
// construct client state based on test case parameters
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientState := suite.chainA.GetClientState(clientA).(*types.ClientState)
|
||||
clientState.AllowUpdateAfterExpiry = tc.AllowUpdateAfterExpiry
|
||||
clientState.AllowUpdateAfterMisbehaviour = tc.AllowUpdateAfterMisbehaviour
|
||||
@ -320,7 +319,7 @@ func (suite *TendermintTestSuite) TestCheckProposedHeader() {
|
||||
suite.Run(tc.name, func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientState = suite.chainA.GetClientState(clientA).(*types.ClientState)
|
||||
clientState.AllowUpdateAfterExpiry = true
|
||||
clientState.AllowUpdateAfterMisbehaviour = false
|
||||
|
||||
@ -34,7 +34,7 @@ func (cs ClientState) GetChainID() string {
|
||||
}
|
||||
|
||||
// ClientType is localhost.
|
||||
func (cs ClientState) ClientType() exported.ClientType {
|
||||
func (cs ClientState) ClientType() string {
|
||||
return exported.Localhost
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ func (suite *LocalhostTestSuite) SetupTest() {
|
||||
|
||||
suite.cdc = app.AppCodec()
|
||||
suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: 1, ChainID: "ibc-chain"})
|
||||
suite.store = app.IBCKeeper.ClientKeeper.ClientStore(suite.ctx, exported.ClientTypeLocalHost)
|
||||
suite.store = app.IBCKeeper.ClientKeeper.ClientStore(suite.ctx, exported.Localhost)
|
||||
}
|
||||
|
||||
func TestLocalhostTestSuite(t *testing.T) {
|
||||
|
||||
@ -1,19 +1,25 @@
|
||||
package exported
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
ics23 "github.com/confio/ics23/go"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
const (
|
||||
// TypeClientMisbehaviour is the shared evidence misbehaviour type
|
||||
TypeClientMisbehaviour string = "client_misbehaviour"
|
||||
|
||||
// Localhost is the client type for a localhost client. It is also used as the clientID
|
||||
// for the localhost client.
|
||||
Localhost string = "localhost"
|
||||
)
|
||||
|
||||
// ClientState defines the required common functions for light clients.
|
||||
type ClientState interface {
|
||||
ClientType() ClientType
|
||||
ClientType() string
|
||||
GetLatestHeight() Height
|
||||
IsFrozen() bool
|
||||
GetFrozenHeight() Height
|
||||
@ -114,7 +120,7 @@ type ClientState interface {
|
||||
|
||||
// ConsensusState is the state of the consensus process
|
||||
type ConsensusState interface {
|
||||
ClientType() ClientType // Consensus kind
|
||||
ClientType() string // Consensus kind
|
||||
|
||||
// GetRoot returns the commitment root of the consensus state,
|
||||
// which is used for key-value pair verification.
|
||||
@ -126,12 +132,9 @@ type ConsensusState interface {
|
||||
ValidateBasic() error
|
||||
}
|
||||
|
||||
// TypeClientMisbehaviour is the shared evidence misbehaviour type
|
||||
const TypeClientMisbehaviour string = "client_misbehaviour"
|
||||
|
||||
// Misbehaviour defines counterparty misbehaviour for a specific consensus type
|
||||
type Misbehaviour interface {
|
||||
ClientType() ClientType
|
||||
ClientType() string
|
||||
GetClientID() string
|
||||
String() string
|
||||
ValidateBasic() error
|
||||
@ -142,7 +145,7 @@ type Misbehaviour interface {
|
||||
|
||||
// Header is the consensus state update information
|
||||
type Header interface {
|
||||
ClientType() ClientType
|
||||
ClientType() string
|
||||
GetHeight() Height
|
||||
ValidateBasic() error
|
||||
}
|
||||
@ -161,70 +164,3 @@ type Height interface {
|
||||
Decrement() (Height, bool)
|
||||
String() string
|
||||
}
|
||||
|
||||
// ClientType defines the type of the consensus algorithm
|
||||
type ClientType byte
|
||||
|
||||
// available client types
|
||||
const (
|
||||
SoloMachine ClientType = 6
|
||||
Tendermint ClientType = 7
|
||||
Localhost ClientType = 9
|
||||
)
|
||||
|
||||
// string representation of the client types
|
||||
const (
|
||||
ClientTypeSoloMachine string = "solomachine"
|
||||
ClientTypeTendermint string = "tendermint"
|
||||
ClientTypeLocalHost string = "localhost"
|
||||
)
|
||||
|
||||
func (ct ClientType) String() string {
|
||||
switch ct {
|
||||
case SoloMachine:
|
||||
return ClientTypeSoloMachine
|
||||
case Tendermint:
|
||||
return ClientTypeTendermint
|
||||
case Localhost:
|
||||
return ClientTypeLocalHost
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalJSON marshal to JSON using string.
|
||||
func (ct ClientType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(ct.String())
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes from JSON.
|
||||
func (ct *ClientType) UnmarshalJSON(data []byte) error {
|
||||
var s string
|
||||
err := json.Unmarshal(data, &s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientType := ClientTypeFromString(s)
|
||||
if clientType == 0 {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "invalid client type '%s'", s)
|
||||
}
|
||||
|
||||
*ct = clientType
|
||||
return nil
|
||||
}
|
||||
|
||||
// ClientTypeFromString returns a byte that corresponds to the registered client
|
||||
// type. It returns 0 if the type is not found/registered.
|
||||
func ClientTypeFromString(clientType string) ClientType {
|
||||
switch clientType {
|
||||
case ClientTypeSoloMachine:
|
||||
return SoloMachine
|
||||
case ClientTypeTendermint:
|
||||
return Tendermint
|
||||
case ClientTypeLocalHost:
|
||||
return Localhost
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
package exported
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestClientTypeString(t *testing.T) {
|
||||
cases := []struct {
|
||||
msg string
|
||||
name string
|
||||
clientType ClientType
|
||||
}{
|
||||
{"solomachine client", ClientTypeSoloMachine, SoloMachine},
|
||||
{"tendermint client", ClientTypeTendermint, Tendermint},
|
||||
{"localhost client", ClientTypeLocalHost, Localhost},
|
||||
{"empty type", "", 0},
|
||||
}
|
||||
|
||||
for _, tt := range cases {
|
||||
tt := tt
|
||||
require.Equal(t, tt.clientType, ClientTypeFromString(tt.name), tt.msg)
|
||||
require.Equal(t, tt.name, tt.clientType.String(), tt.msg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientTypeMarshalJSON(t *testing.T) {
|
||||
cases := []struct {
|
||||
msg string
|
||||
name string
|
||||
clientType ClientType
|
||||
expectPass bool
|
||||
}{
|
||||
{"solomachine client", ClientTypeSoloMachine, SoloMachine, true},
|
||||
{"tendermint client", ClientTypeTendermint, Tendermint, true},
|
||||
{"localhost client", ClientTypeLocalHost, Localhost, true},
|
||||
{"empty type should have failed", "", 0, false},
|
||||
}
|
||||
|
||||
for _, tt := range cases {
|
||||
tt := tt
|
||||
bz, err := tt.clientType.MarshalJSON()
|
||||
require.NoError(t, err)
|
||||
var ct ClientType
|
||||
if tt.expectPass {
|
||||
require.NoError(t, ct.UnmarshalJSON(bz), tt.msg)
|
||||
require.Equal(t, tt.name, ct.String(), tt.msg)
|
||||
} else {
|
||||
require.Error(t, ct.UnmarshalJSON(bz), tt.msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,7 +40,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
),
|
||||
clienttypes.NewIdentifiedClientState(
|
||||
exported.ClientTypeLocalHost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
),
|
||||
},
|
||||
[]clienttypes.ClientConsensusStates{
|
||||
@ -103,7 +103,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
),
|
||||
clienttypes.NewIdentifiedClientState(
|
||||
exported.ClientTypeLocalHost, localhosttypes.NewClientState("(chaindID)", clienttypes.ZeroHeight()),
|
||||
exported.Localhost, localhosttypes.NewClientState("(chaindID)", clienttypes.ZeroHeight()),
|
||||
),
|
||||
},
|
||||
nil,
|
||||
@ -172,7 +172,7 @@ func (suite *IBCTestSuite) TestInitGenesis() {
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
),
|
||||
clienttypes.NewIdentifiedClientState(
|
||||
exported.ClientTypeLocalHost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight),
|
||||
),
|
||||
},
|
||||
[]clienttypes.ClientConsensusStates{
|
||||
@ -248,8 +248,8 @@ func (suite *HandlerTestSuite) TestExportGenesis() {
|
||||
// creates clients
|
||||
suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED)
|
||||
// create extra clients
|
||||
suite.coordinator.CreateClient(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
suite.coordinator.CreateClient(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
suite.coordinator.CreateClient(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
suite.coordinator.CreateClient(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
@ -324,7 +323,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// need to update chainA client to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
}, true},
|
||||
@ -337,7 +336,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// need to update chainA client to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
}, true},
|
||||
@ -355,7 +354,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() {
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
|
||||
}, true},
|
||||
@ -372,7 +371,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() {
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
|
||||
}, true},
|
||||
@ -454,7 +453,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// need to update chainA client to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
|
||||
@ -476,7 +475,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// need to update chainA client to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
|
||||
@ -504,7 +503,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
|
||||
}
|
||||
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
|
||||
// close counterparty channel
|
||||
@ -529,7 +528,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
|
||||
// close counterparty channel
|
||||
@ -570,7 +569,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// need to update chainA client to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint)
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
|
||||
|
||||
@ -14,6 +14,9 @@ import (
|
||||
|
||||
var _ exported.ClientState = (*ClientState)(nil)
|
||||
|
||||
// SoloMachine is used to indicate that the light client is a solo machine.
|
||||
const SoloMachine string = "Solo Machine"
|
||||
|
||||
// NewClientState creates a new ClientState instance.
|
||||
func NewClientState(latestSequence uint64, consensusState *ConsensusState, allowUpdateAfterProposal bool) *ClientState {
|
||||
return &ClientState{
|
||||
@ -25,8 +28,8 @@ func NewClientState(latestSequence uint64, consensusState *ConsensusState, allow
|
||||
}
|
||||
|
||||
// ClientType is Solo Machine.
|
||||
func (cs ClientState) ClientType() exported.ClientType {
|
||||
return exported.SoloMachine
|
||||
func (cs ClientState) ClientType() string {
|
||||
return SoloMachine
|
||||
}
|
||||
|
||||
// GetLatestHeight returns the latest sequence number.
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -78,7 +79,7 @@ func (suite *SoloMachineTestSuite) TestClientStateValidateBasic() {
|
||||
|
||||
func (suite *SoloMachineTestSuite) TestVerifyClientState() {
|
||||
// create client for tendermint so we can use client state for verification
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientState := suite.chainA.GetClientState(clientA)
|
||||
|
||||
clientPrefixedPath := "clients/" + counterpartyClientIdentifier + "/" + host.ClientStatePath()
|
||||
@ -204,7 +205,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() {
|
||||
|
||||
func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() {
|
||||
// create client for tendermint so we can use consensus state for verification
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint)
|
||||
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
||||
clientState := suite.chainA.GetClientState(clientA)
|
||||
consensusState, found := suite.chainA.GetConsensusState(clientA, clientState.GetLatestHeight())
|
||||
suite.Require().True(found)
|
||||
|
||||
@ -13,8 +13,8 @@ import (
|
||||
var _ exported.ConsensusState = ConsensusState{}
|
||||
|
||||
// ClientType returns Solo Machine type.
|
||||
func (ConsensusState) ClientType() exported.ClientType {
|
||||
return exported.SoloMachine
|
||||
func (ConsensusState) ClientType() string {
|
||||
return SoloMachine
|
||||
}
|
||||
|
||||
// GetTimestamp returns zero.
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types"
|
||||
)
|
||||
|
||||
func (suite *SoloMachineTestSuite) TestConsensusState() {
|
||||
consensusState := suite.solomachine.ConsensusState()
|
||||
|
||||
suite.Require().Equal(exported.SoloMachine, consensusState.ClientType())
|
||||
suite.Require().Equal(types.SoloMachine, consensusState.ClientType())
|
||||
suite.Require().Equal(suite.solomachine.Time, consensusState.GetTimestamp())
|
||||
suite.Require().Nil(consensusState.GetRoot())
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@ import (
|
||||
var _ exported.Header = Header{}
|
||||
|
||||
// ClientType defines that the Header is a Solo Machine.
|
||||
func (Header) ClientType() exported.ClientType {
|
||||
return exported.SoloMachine
|
||||
func (Header) ClientType() string {
|
||||
return SoloMachine
|
||||
}
|
||||
|
||||
// GetHeight returns the current sequence number as the height.
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types"
|
||||
)
|
||||
|
||||
@ -75,7 +74,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() {
|
||||
},
|
||||
}
|
||||
|
||||
suite.Require().Equal(exported.SoloMachine, header.ClientType())
|
||||
suite.Require().Equal(types.SoloMachine, header.ClientType())
|
||||
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
|
||||
@ -16,8 +16,8 @@ var (
|
||||
)
|
||||
|
||||
// ClientType is a Solo Machine light client.
|
||||
func (misbehaviour Misbehaviour) ClientType() exported.ClientType {
|
||||
return exported.SoloMachine
|
||||
func (misbehaviour Misbehaviour) ClientType() string {
|
||||
return SoloMachine
|
||||
}
|
||||
|
||||
// GetClientID returns the ID of the client that committed a misbehaviour.
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types"
|
||||
)
|
||||
|
||||
func (suite *SoloMachineTestSuite) TestMisbehaviour() {
|
||||
misbehaviour := suite.solomachine.CreateMisbehaviour()
|
||||
|
||||
suite.Require().Equal(exported.SoloMachine, misbehaviour.ClientType())
|
||||
suite.Require().Equal(types.SoloMachine, misbehaviour.ClientType())
|
||||
suite.Require().Equal(suite.solomachine.ClientID, misbehaviour.GetClientID())
|
||||
suite.Require().Equal(uint64(0), misbehaviour.GetHeight().GetEpochNumber())
|
||||
suite.Require().Equal(suite.solomachine.Sequence, misbehaviour.GetHeight().GetEpochHeight())
|
||||
|
||||
@ -38,7 +38,7 @@ func (suite *SoloMachineTestSuite) SetupTest() {
|
||||
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1))
|
||||
|
||||
suite.solomachine = ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "testingsolomachine", "testing")
|
||||
suite.store = suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), exported.ClientTypeSoloMachine)
|
||||
suite.store = suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), types.SoloMachine)
|
||||
|
||||
bz, err := codec.MarshalAny(suite.chainA.Codec, suite.solomachine.ClientState())
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -31,12 +31,17 @@ import (
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
solomachinetypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/testing/mock"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
const (
|
||||
// client types
|
||||
Tendermint = ibctmtypes.Tendermint
|
||||
SoloMachine = solomachinetypes.SoloMachine
|
||||
|
||||
// Default params constants used to create a TM client
|
||||
TrustingPeriod time.Duration = time.Hour * 24 * 7 * 2
|
||||
UnbondingPeriod time.Duration = time.Hour * 24 * 7 * 3
|
||||
@ -380,7 +385,7 @@ func (chain *TestChain) ConstructMsgCreateClient(counterparty *TestChain, client
|
||||
)
|
||||
|
||||
switch clientType {
|
||||
case exported.ClientTypeTendermint:
|
||||
case Tendermint:
|
||||
height := counterparty.LastHeader.GetHeight().(clienttypes.Height)
|
||||
clientState = ibctmtypes.NewClientState(
|
||||
counterparty.ChainID, DefaultTrustLevel, TrustingPeriod, UnbondingPeriod, MaxClockDrift,
|
||||
@ -388,7 +393,7 @@ func (chain *TestChain) ConstructMsgCreateClient(counterparty *TestChain, client
|
||||
false, false,
|
||||
)
|
||||
consensusState = counterparty.LastHeader.ConsensusState()
|
||||
case exported.ClientTypeSoloMachine:
|
||||
case SoloMachine:
|
||||
solo := NewSolomachine(chain.t, chain.Codec, clientID, "")
|
||||
clientState = solo.ClientState()
|
||||
consensusState = solo.ConsensusState()
|
||||
@ -407,7 +412,7 @@ func (chain *TestChain) ConstructMsgCreateClient(counterparty *TestChain, client
|
||||
// client will be created on the (target) chain.
|
||||
func (chain *TestChain) CreateTMClient(counterparty *TestChain, clientID string) error {
|
||||
// construct MsgCreateClient using counterparty
|
||||
msg := chain.ConstructMsgCreateClient(counterparty, clientID, exported.ClientTypeTendermint)
|
||||
msg := chain.ConstructMsgCreateClient(counterparty, clientID, Tendermint)
|
||||
return chain.sendMsgs(msg)
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ func NewCoordinator(t *testing.T, n int) *Coordinator {
|
||||
func (coord *Coordinator) Setup(
|
||||
chainA, chainB *TestChain, order channeltypes.Order,
|
||||
) (string, string, *TestConnection, *TestConnection, TestChannel, TestChannel) {
|
||||
clientA, clientB, connA, connB := coord.SetupClientConnections(chainA, chainB, exported.Tendermint)
|
||||
clientA, clientB, connA, connB := coord.SetupClientConnections(chainA, chainB, Tendermint)
|
||||
|
||||
// channels can also be referenced through the returned connections
|
||||
channelA, channelB := coord.CreateMockChannels(chainA, chainB, connA, connB, order)
|
||||
@ -61,7 +61,7 @@ func (coord *Coordinator) Setup(
|
||||
// caller does not anticipate any errors.
|
||||
func (coord *Coordinator) SetupClients(
|
||||
chainA, chainB *TestChain,
|
||||
clientType exported.ClientType,
|
||||
clientType string,
|
||||
) (string, string) {
|
||||
|
||||
clientA, err := coord.CreateClient(chainA, chainB, clientType)
|
||||
@ -78,7 +78,7 @@ func (coord *Coordinator) SetupClients(
|
||||
// anticipate any errors.
|
||||
func (coord *Coordinator) SetupClientConnections(
|
||||
chainA, chainB *TestChain,
|
||||
clientType exported.ClientType,
|
||||
clientType string,
|
||||
) (string, string, *TestConnection, *TestConnection) {
|
||||
|
||||
clientA, clientB := coord.SetupClients(chainA, chainB, clientType)
|
||||
@ -91,14 +91,14 @@ func (coord *Coordinator) SetupClientConnections(
|
||||
// CreateClient creates a counterparty client on the source chain and returns the clientID.
|
||||
func (coord *Coordinator) CreateClient(
|
||||
source, counterparty *TestChain,
|
||||
clientType exported.ClientType,
|
||||
clientType string,
|
||||
) (clientID string, err error) {
|
||||
coord.CommitBlock(source, counterparty)
|
||||
|
||||
clientID = source.NewClientID(counterparty.ChainID)
|
||||
|
||||
switch clientType {
|
||||
case exported.Tendermint:
|
||||
case Tendermint:
|
||||
err = source.CreateTMClient(counterparty, clientID)
|
||||
|
||||
default:
|
||||
@ -118,12 +118,12 @@ func (coord *Coordinator) CreateClient(
|
||||
func (coord *Coordinator) UpdateClient(
|
||||
source, counterparty *TestChain,
|
||||
clientID string,
|
||||
clientType exported.ClientType,
|
||||
clientType string,
|
||||
) (err error) {
|
||||
coord.CommitBlock(source, counterparty)
|
||||
|
||||
switch clientType {
|
||||
case exported.Tendermint:
|
||||
case Tendermint:
|
||||
err = source.UpdateTMClient(counterparty, clientID)
|
||||
|
||||
default:
|
||||
@ -226,7 +226,7 @@ func (coord *Coordinator) SendPacket(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
counterpartyClientID, exported.Tendermint,
|
||||
counterpartyClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ func (coord *Coordinator) ReceiveExecuted(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
counterpartyClientID, exported.Tendermint,
|
||||
counterpartyClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ func (coord *Coordinator) AcknowledgementExecuted(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
counterpartyClientID, exported.Tendermint,
|
||||
counterpartyClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -346,7 +346,7 @@ func (coord *Coordinator) SendMsgs(source, counterparty *TestChain, counterparty
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
counterpartyClientID, exported.Tendermint,
|
||||
counterpartyClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -405,7 +405,7 @@ func (coord *Coordinator) ConnOpenInit(
|
||||
// update source client on counterparty connection
|
||||
if err := coord.UpdateClient(
|
||||
counterparty, source,
|
||||
counterpartyClientID, exported.Tendermint,
|
||||
counterpartyClientID, Tendermint,
|
||||
); err != nil {
|
||||
return sourceConnection, counterpartyConnection, err
|
||||
}
|
||||
@ -428,7 +428,7 @@ func (coord *Coordinator) ConnOpenTry(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
counterpartyConnection.ClientID, exported.Tendermint,
|
||||
counterpartyConnection.ClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ func (coord *Coordinator) ConnOpenAck(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
counterpartyConnection.ClientID, exported.Tendermint,
|
||||
counterpartyConnection.ClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -465,7 +465,7 @@ func (coord *Coordinator) ConnOpenConfirm(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
counterpartyConnection.ClientID, exported.Tendermint,
|
||||
counterpartyConnection.ClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -497,7 +497,7 @@ func (coord *Coordinator) ChanOpenInit(
|
||||
// update source client on counterparty connection
|
||||
if err := coord.UpdateClient(
|
||||
counterparty, source,
|
||||
counterpartyConnection.ClientID, exported.Tendermint,
|
||||
counterpartyConnection.ClientID, Tendermint,
|
||||
); err != nil {
|
||||
return sourceChannel, counterpartyChannel, err
|
||||
}
|
||||
@ -523,7 +523,7 @@ func (coord *Coordinator) ChanOpenTry(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
connection.CounterpartyClientID, exported.Tendermint,
|
||||
connection.CounterpartyClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -542,7 +542,7 @@ func (coord *Coordinator) ChanOpenAck(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
sourceChannel.CounterpartyClientID, exported.Tendermint,
|
||||
sourceChannel.CounterpartyClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -561,7 +561,7 @@ func (coord *Coordinator) ChanOpenConfirm(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
sourceChannel.CounterpartyClientID, exported.Tendermint,
|
||||
sourceChannel.CounterpartyClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -582,7 +582,7 @@ func (coord *Coordinator) ChanCloseInit(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
channel.CounterpartyClientID, exported.Tendermint,
|
||||
channel.CounterpartyClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
@ -601,6 +601,6 @@ func (coord *Coordinator) SetChannelClosed(
|
||||
// update source client on counterparty connection
|
||||
return coord.UpdateClient(
|
||||
counterparty, source,
|
||||
testChannel.CounterpartyClientID, exported.Tendermint,
|
||||
testChannel.CounterpartyClientID, Tendermint,
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user