github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/wasm/ibctesting/endpoint.go (about)

     1  package ibctesting
     2  
     3  //import (
     4  //	"fmt"
     5  //
     6  //	ibctesting "github.com/cosmos/ibc-go/v3/testing"
     7  //
     8  //	//	sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
     9  //	"github.com/stretchr/testify/require"
    10  //
    11  //	clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
    12  //	connectiontypes "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types"
    13  //	channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
    14  //	commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types"
    15  //	host "github.com/cosmos/ibc-go/v3/modules/core/24-host"
    16  //	"github.com/cosmos/ibc-go/v3/modules/core/exported"
    17  //	ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"
    18  //)
    19  //
    20  //// Endpoint is a which represents a channel endpoint and its associated
    21  //// client and connections. It contains client, connection, and channel
    22  //// configuration parameters. Endpoint functions will utilize the parameters
    23  //// set in the configuration structs when executing IBC messages.
    24  //type Endpoint struct {
    25  //	Chain        *TestChain
    26  //	Counterparty *Endpoint
    27  //	ClientID     string
    28  //	ConnectionID string
    29  //	ChannelID    string
    30  //
    31  //	ClientConfig     ibctesting.ClientConfig
    32  //	ConnectionConfig *ibctesting.ConnectionConfig
    33  //	ChannelConfig    *ibctesting.ChannelConfig
    34  //}
    35  //
    36  //// NewEndpoint constructs a new endpoint without the counterparty.
    37  //// CONTRACT: the counterparty endpoint must be set by the caller.
    38  //func NewEndpoint(
    39  //	chain *TestChain, clientConfig ibctesting.ClientConfig,
    40  //	connectionConfig *ibctesting.ConnectionConfig, channelConfig *ibctesting.ChannelConfig,
    41  //) *Endpoint {
    42  //	return &Endpoint{
    43  //		Chain:            chain,
    44  //		ClientConfig:     clientConfig,
    45  //		ConnectionConfig: connectionConfig,
    46  //		ChannelConfig:    channelConfig,
    47  //	}
    48  //}
    49  //
    50  //// NewDefaultEndpoint constructs a new endpoint using default values.
    51  //// CONTRACT: the counterparty endpoitn must be set by the caller.
    52  //func NewDefaultEndpoint(chain *TestChain) *Endpoint {
    53  //	return &Endpoint{
    54  //		Chain:            chain,
    55  //		ClientConfig:     ibctesting.NewTendermintConfig(),
    56  //		ConnectionConfig: ibctesting.NewConnectionConfig(),
    57  //		ChannelConfig:    ibctesting.NewChannelConfig(),
    58  //	}
    59  //}
    60  //
    61  //// QueryProof queries proof associated with this endpoint using the lastest client state
    62  //// height on the counterparty chain.
    63  //func (endpoint *Endpoint) QueryProof(key []byte) ([]byte, clienttypes.Height) {
    64  //	// obtain the counterparty client representing the chain associated with the endpoint
    65  //	clientState := endpoint.Counterparty.Chain.GetClientState(endpoint.Counterparty.ClientID)
    66  //
    67  //	// query proof on the counterparty using the latest height of the IBC client
    68  //	return endpoint.QueryProofAtHeight(key, clientState.GetLatestHeight().GetRevisionHeight())
    69  //}
    70  //
    71  //// QueryProofAtHeight queries proof associated with this endpoint using the proof height
    72  //// providied
    73  //func (endpoint *Endpoint) QueryProofAtHeight(key []byte, height uint64) ([]byte, clienttypes.Height) {
    74  //	// query proof on the counterparty using the latest height of the IBC client
    75  //	return endpoint.Chain.QueryProofAtHeight(key, int64(height))
    76  //}
    77  //
    78  //// CreateClient creates an IBC client on the endpoint. It will update the
    79  //// clientID for the endpoint if the message is successfully executed.
    80  //// NOTE: a solo machine client will be created with an empty diversifier.
    81  //func (endpoint *Endpoint) CreateClient() (err error) {
    82  //	// ensure counterparty has committed state
    83  //	endpoint.Chain.Coordinator.CommitBlock(endpoint.Counterparty.Chain)
    84  //
    85  //	var (
    86  //		clientState    exported.ClientState
    87  //		consensusState exported.ConsensusState
    88  //	)
    89  //
    90  //	switch endpoint.ClientConfig.GetClientType() {
    91  //	case exported.Tendermint:
    92  //		tmConfig, ok := endpoint.ClientConfig.(*ibctesting.TendermintConfig)
    93  //		require.True(endpoint.Chain.t, ok)
    94  //
    95  //		height := endpoint.Counterparty.Chain.LastHeader.GetHeight().(clienttypes.Height)
    96  //		clientState = ibctmtypes.NewClientState(
    97  //			endpoint.Counterparty.Chain.ChainID, tmConfig.TrustLevel, tmConfig.TrustingPeriod, tmConfig.UnbondingPeriod, tmConfig.MaxClockDrift,
    98  //			height, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, tmConfig.AllowUpdateAfterExpiry, tmConfig.AllowUpdateAfterMisbehaviour,
    99  //		)
   100  //		consensusState = endpoint.Counterparty.Chain.LastHeader.ConsensusState()
   101  //	case exported.Solomachine:
   102  //		// TODO
   103  //		//		solo := NewSolomachine(chain.t, endpoint.Chain.Codec, clientID, "", 1)
   104  //		//		clientState = solo.ClientState()
   105  //		//		consensusState = solo.ConsensusState()
   106  //
   107  //	default:
   108  //		err = fmt.Errorf("client type %s is not supported", endpoint.ClientConfig.GetClientType())
   109  //	}
   110  //
   111  //	if err != nil {
   112  //		return err
   113  //	}
   114  //
   115  //	msg, err := clienttypes.NewMsgCreateClient(
   116  //		clientState, consensusState, endpoint.Chain.SenderAccount.GetAddress().String(),
   117  //	)
   118  //	require.NoError(endpoint.Chain.t, err)
   119  //
   120  //	res, err := endpoint.Chain.SendMsgs(msg)
   121  //	if err != nil {
   122  //		return err
   123  //	}
   124  //
   125  //	endpoint.ClientID, err = ibctesting.ParseClientIDFromEvents(res.GetEvents())
   126  //	require.NoError(endpoint.Chain.t, err)
   127  //
   128  //	return nil
   129  //}
   130  //
   131  //// UpdateClient updates the IBC client associated with the endpoint.
   132  //func (endpoint *Endpoint) UpdateClient() (err error) {
   133  //	// ensure counterparty has committed state
   134  //	endpoint.Chain.Coordinator.CommitBlock(endpoint.Counterparty.Chain)
   135  //
   136  //	var header exported.Header
   137  //
   138  //	switch endpoint.ClientConfig.GetClientType() {
   139  //	case exported.Tendermint:
   140  //		header, err = endpoint.Chain.ConstructUpdateTMClientHeader(endpoint.Counterparty.Chain, endpoint.ClientID)
   141  //
   142  //	default:
   143  //		err = fmt.Errorf("client type %s is not supported", endpoint.ClientConfig.GetClientType())
   144  //	}
   145  //
   146  //	if err != nil {
   147  //		return err
   148  //	}
   149  //
   150  //	msg, err := clienttypes.NewMsgUpdateClient(
   151  //		endpoint.ClientID, header,
   152  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   153  //	)
   154  //	require.NoError(endpoint.Chain.t, err)
   155  //
   156  //	return endpoint.Chain.sendMsgs(msg)
   157  //}
   158  //
   159  //// ConnOpenInit will construct and execute a MsgConnectionOpenInit on the associated endpoint.
   160  //func (endpoint *Endpoint) ConnOpenInit() error {
   161  //	msg := connectiontypes.NewMsgConnectionOpenInit(
   162  //		endpoint.ClientID,
   163  //		endpoint.Counterparty.ClientID,
   164  //		endpoint.Counterparty.Chain.GetPrefix(), ibctesting.DefaultOpenInitVersion, endpoint.ConnectionConfig.DelayPeriod,
   165  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   166  //	)
   167  //	res, err := endpoint.Chain.SendMsgs(msg)
   168  //	if err != nil {
   169  //		return err
   170  //	}
   171  //
   172  //	endpoint.ConnectionID, err = ibctesting.ParseConnectionIDFromEvents(res.GetEvents())
   173  //	require.NoError(endpoint.Chain.t, err)
   174  //
   175  //	return nil
   176  //}
   177  //
   178  //// ConnOpenTry will construct and execute a MsgConnectionOpenTry on the associated endpoint.
   179  //func (endpoint *Endpoint) ConnOpenTry() error {
   180  //	if err := endpoint.UpdateClient(); err != nil {
   181  //		return err
   182  //	}
   183  //
   184  //	counterpartyClient, proofClient, proofConsensus, consensusHeight, proofInit, proofHeight := endpoint.QueryConnectionHandshakeProof()
   185  //
   186  //	msg := connectiontypes.NewMsgConnectionOpenTry(
   187  //		"", endpoint.ClientID, // does not support handshake continuation
   188  //		endpoint.Counterparty.ConnectionID, endpoint.Counterparty.ClientID,
   189  //		counterpartyClient, endpoint.Counterparty.Chain.GetPrefix(), []*connectiontypes.Version{ibctesting.ConnectionVersion}, endpoint.ConnectionConfig.DelayPeriod,
   190  //		proofInit, proofClient, proofConsensus,
   191  //		proofHeight, consensusHeight,
   192  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   193  //	)
   194  //	res, err := endpoint.Chain.SendMsgs(msg)
   195  //	if err != nil {
   196  //		return err
   197  //	}
   198  //
   199  //	if endpoint.ConnectionID == "" {
   200  //		endpoint.ConnectionID, err = ibctesting.ParseConnectionIDFromEvents(res.GetEvents())
   201  //		require.NoError(endpoint.Chain.t, err)
   202  //	}
   203  //
   204  //	return nil
   205  //}
   206  //
   207  //// ConnOpenAck will construct and execute a MsgConnectionOpenAck on the associated endpoint.
   208  //func (endpoint *Endpoint) ConnOpenAck() error {
   209  //	if err := endpoint.UpdateClient(); err != nil {
   210  //		return err
   211  //	}
   212  //
   213  //	counterpartyClient, proofClient, proofConsensus, consensusHeight, proofTry, proofHeight := endpoint.QueryConnectionHandshakeProof()
   214  //
   215  //	msg := connectiontypes.NewMsgConnectionOpenAck(
   216  //		endpoint.ConnectionID, endpoint.Counterparty.ConnectionID, counterpartyClient, // testing doesn't use flexible selection
   217  //		proofTry, proofClient, proofConsensus,
   218  //		proofHeight, consensusHeight,
   219  //		ibctesting.ConnectionVersion,
   220  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   221  //	)
   222  //	return endpoint.Chain.sendMsgs(msg)
   223  //}
   224  //
   225  //// ConnOpenConfirm will construct and execute a MsgConnectionOpenConfirm on the associated endpoint.
   226  //func (endpoint *Endpoint) ConnOpenConfirm() error {
   227  //	if err := endpoint.UpdateClient(); err != nil {
   228  //		return err
   229  //	}
   230  //
   231  //	connectionKey := host.ConnectionKey(endpoint.Counterparty.ConnectionID)
   232  //	proof, height := endpoint.Counterparty.Chain.QueryProof(connectionKey)
   233  //
   234  //	msg := connectiontypes.NewMsgConnectionOpenConfirm(
   235  //		endpoint.ConnectionID,
   236  //		proof, height,
   237  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   238  //	)
   239  //	return endpoint.Chain.sendMsgs(msg)
   240  //}
   241  //
   242  //// QueryConnectionHandshakeProof returns all the proofs necessary to execute OpenTry or Open Ack of
   243  //// the connection handshakes. It returns the counterparty client state, proof of the counterparty
   244  //// client state, proof of the counterparty consensus state, the consensus state height, proof of
   245  //// the counterparty connection, and the proof height for all the proofs returned.
   246  //func (endpoint *Endpoint) QueryConnectionHandshakeProof() (
   247  //	clientState exported.ClientState, proofClient,
   248  //	proofConsensus []byte, consensusHeight clienttypes.Height,
   249  //	proofConnection []byte, proofHeight clienttypes.Height,
   250  //) {
   251  //	// obtain the client state on the counterparty chain
   252  //	clientState = endpoint.Counterparty.Chain.GetClientState(endpoint.Counterparty.ClientID)
   253  //
   254  //	// query proof for the client state on the counterparty
   255  //	clientKey := host.FullClientStateKey(endpoint.Counterparty.ClientID)
   256  //	proofClient, proofHeight = endpoint.Counterparty.QueryProof(clientKey)
   257  //
   258  //	consensusHeight = clientState.GetLatestHeight().(clienttypes.Height)
   259  //
   260  //	// query proof for the consensus state on the counterparty
   261  //	consensusKey := host.FullConsensusStateKey(endpoint.Counterparty.ClientID, consensusHeight)
   262  //	proofConsensus, _ = endpoint.Counterparty.QueryProofAtHeight(consensusKey, proofHeight.GetRevisionHeight())
   263  //
   264  //	// query proof for the connection on the counterparty
   265  //	connectionKey := host.ConnectionKey(endpoint.Counterparty.ConnectionID)
   266  //	proofConnection, _ = endpoint.Counterparty.QueryProofAtHeight(connectionKey, proofHeight.GetRevisionHeight())
   267  //
   268  //	return
   269  //}
   270  //
   271  //// ChanOpenInit will construct and execute a MsgChannelOpenInit on the associated endpoint.
   272  //func (endpoint *Endpoint) ChanOpenInit() error {
   273  //	msg := channeltypes.NewMsgChannelOpenInit(
   274  //		endpoint.ChannelConfig.PortID,
   275  //		endpoint.ChannelConfig.Version, endpoint.ChannelConfig.Order, []string{endpoint.ConnectionID},
   276  //		endpoint.Counterparty.ChannelConfig.PortID,
   277  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   278  //	)
   279  //	res, err := endpoint.Chain.SendMsgs(msg)
   280  //	if err != nil {
   281  //		return err
   282  //	}
   283  //
   284  //	endpoint.ChannelID, err = ibctesting.ParseChannelIDFromEvents(res.GetEvents())
   285  //	require.NoError(endpoint.Chain.t, err)
   286  //
   287  //	return nil
   288  //}
   289  //
   290  //// ChanOpenTry will construct and execute a MsgChannelOpenTry on the associated endpoint.
   291  //func (endpoint *Endpoint) ChanOpenTry() error {
   292  //	if err := endpoint.UpdateClient(); err != nil {
   293  //		return err
   294  //	}
   295  //
   296  //	channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID)
   297  //	proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey)
   298  //
   299  //	msg := channeltypes.NewMsgChannelOpenTry(
   300  //		endpoint.ChannelConfig.PortID, "", // does not support handshake continuation
   301  //		endpoint.ChannelConfig.Version, endpoint.ChannelConfig.Order, []string{endpoint.ConnectionID},
   302  //		endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID, endpoint.Counterparty.ChannelConfig.Version,
   303  //		proof, height,
   304  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   305  //	)
   306  //	res, err := endpoint.Chain.SendMsgs(msg)
   307  //	if err != nil {
   308  //		return err
   309  //	}
   310  //
   311  //	if endpoint.ChannelID == "" {
   312  //		endpoint.ChannelID, err = ibctesting.ParseChannelIDFromEvents(res.GetEvents())
   313  //		require.NoError(endpoint.Chain.t, err)
   314  //	}
   315  //
   316  //	return nil
   317  //}
   318  //
   319  //// ChanOpenAck will construct and execute a MsgChannelOpenAck on the associated endpoint.
   320  //func (endpoint *Endpoint) ChanOpenAck() error {
   321  //	if err := endpoint.UpdateClient(); err != nil {
   322  //		return err
   323  //	}
   324  //
   325  //	channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID)
   326  //	proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey)
   327  //
   328  //	msg := channeltypes.NewMsgChannelOpenAck(
   329  //		endpoint.ChannelConfig.PortID, endpoint.ChannelID,
   330  //		endpoint.Counterparty.ChannelID, endpoint.Counterparty.ChannelConfig.Version, // testing doesn't use flexible selection
   331  //		proof, height,
   332  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   333  //	)
   334  //	return endpoint.Chain.sendMsgs(msg)
   335  //}
   336  //
   337  //// ChanOpenConfirm will construct and execute a MsgChannelOpenConfirm on the associated endpoint.
   338  //func (endpoint *Endpoint) ChanOpenConfirm() error {
   339  //	if err := endpoint.UpdateClient(); err != nil {
   340  //		return err
   341  //	}
   342  //
   343  //	channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID)
   344  //	proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey)
   345  //
   346  //	msg := channeltypes.NewMsgChannelOpenConfirm(
   347  //		endpoint.ChannelConfig.PortID, endpoint.ChannelID,
   348  //		proof, height,
   349  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   350  //	)
   351  //	return endpoint.Chain.sendMsgs(msg)
   352  //}
   353  //
   354  //// ChanCloseInit will construct and execute a MsgChannelCloseInit on the associated endpoint.
   355  ////
   356  //// NOTE: does not work with ibc-transfer module
   357  //func (endpoint *Endpoint) ChanCloseInit() error {
   358  //	msg := channeltypes.NewMsgChannelCloseInit(
   359  //		endpoint.ChannelConfig.PortID, endpoint.ChannelID,
   360  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   361  //	)
   362  //	return endpoint.Chain.sendMsgs(msg)
   363  //}
   364  //
   365  //// ChanCloseConfirm will construct and execute a NewMsgChannelCloseConfirm on the associated endpoint.
   366  //func (endpoint *Endpoint) ChanCloseConfirm() error {
   367  //	channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID)
   368  //	proof, proofHeight := endpoint.Counterparty.QueryProof(channelKey)
   369  //
   370  //	msg := channeltypes.NewMsgChannelCloseConfirm(
   371  //		endpoint.ChannelConfig.PortID, endpoint.ChannelID,
   372  //		proof, proofHeight,
   373  //		endpoint.Chain.SenderAccount.GetAddress().String(),
   374  //	)
   375  //	return endpoint.Chain.sendMsgs(msg)
   376  //}
   377  //
   378  //// SendPacket sends a packet through the channel keeper using the associated endpoint
   379  //// The counterparty client is updated so proofs can be sent to the counterparty chain.
   380  //func (endpoint *Endpoint) SendPacket(packet exported.PacketI) error {
   381  //	channelCap := endpoint.Chain.GetChannelCapability(packet.GetSourcePort(), packet.GetSourceChannel())
   382  //
   383  //	// no need to send message, acting as a module
   384  //	err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SendPacket(endpoint.Chain.GetContext(), channelCap, packet)
   385  //	if err != nil {
   386  //		return err
   387  //	}
   388  //
   389  //	// commit changes since no message was sent
   390  //	endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain)
   391  //
   392  //	return endpoint.Counterparty.UpdateClient()
   393  //}
   394  //
   395  //// RecvPacket receives a packet on the associated endpoint.
   396  //// The counterparty client is updated.
   397  //func (endpoint *Endpoint) RecvPacket(packet channeltypes.Packet) error {
   398  //	// get proof of packet commitment on source
   399  //	packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
   400  //	proof, proofHeight := endpoint.Counterparty.Chain.QueryProof(packetKey)
   401  //
   402  //	recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String())
   403  //
   404  //	// receive on counterparty and update source client
   405  //	if err := endpoint.Chain.sendMsgs(recvMsg); err != nil {
   406  //		return err
   407  //	}
   408  //
   409  //	return endpoint.Counterparty.UpdateClient()
   410  //}
   411  //
   412  //// WriteAcknowledgement writes an acknowledgement on the channel associated with the endpoint.
   413  //// The counterparty client is updated.
   414  //func (endpoint *Endpoint) WriteAcknowledgement(ack exported.Acknowledgement, packet exported.PacketI) error {
   415  //	channelCap := endpoint.Chain.GetChannelCapability(packet.GetDestPort(), packet.GetDestChannel())
   416  //
   417  //	// no need to send message, acting as a handler
   418  //	err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.WriteAcknowledgement(endpoint.Chain.GetContext(), channelCap, packet, ack)
   419  //	if err != nil {
   420  //		return err
   421  //	}
   422  //
   423  //	// commit changes since no message was sent
   424  //	endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain)
   425  //
   426  //	return endpoint.Counterparty.UpdateClient()
   427  //}
   428  //
   429  //// AcknowledgePacket sends a MsgAcknowledgement to the channel associated with the endpoint.
   430  //func (endpoint *Endpoint) AcknowledgePacket(packet channeltypes.Packet, ack []byte) error {
   431  //	// get proof of acknowledgement on counterparty
   432  //	packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
   433  //	proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey)
   434  //
   435  //	ackMsg := channeltypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String())
   436  //
   437  //	return endpoint.Chain.sendMsgs(ackMsg)
   438  //}
   439  //
   440  //// TimeoutPacket sends a MsgTimeout to the channel associated with the endpoint.
   441  //func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error {
   442  //	// get proof for timeout based on channel order
   443  //	var packetKey []byte
   444  //
   445  //	switch endpoint.ChannelConfig.Order {
   446  //	case channeltypes.ORDERED:
   447  //		packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
   448  //	case channeltypes.UNORDERED:
   449  //		packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
   450  //	default:
   451  //		return fmt.Errorf("unsupported order type %s", endpoint.ChannelConfig.Order)
   452  //	}
   453  //
   454  //	proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey)
   455  //	nextSeqRecv, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceRecv(endpoint.Counterparty.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID)
   456  //	require.True(endpoint.Chain.t, found)
   457  //
   458  //	timeoutMsg := channeltypes.NewMsgTimeout(
   459  //		packet, nextSeqRecv,
   460  //		proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String(),
   461  //	)
   462  //
   463  //	return endpoint.Chain.sendMsgs(timeoutMsg)
   464  //}
   465  //
   466  //// SetChannelClosed sets a channel state to CLOSED.
   467  //func (endpoint *Endpoint) SetChannelClosed() error {
   468  //	channel := endpoint.GetChannel()
   469  //
   470  //	channel.State = channeltypes.CLOSED
   471  //	endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel)
   472  //
   473  //	endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain)
   474  //
   475  //	return endpoint.Counterparty.UpdateClient()
   476  //}
   477  //
   478  //// GetClientState retrieves the Client State for this endpoint. The
   479  //// client state is expected to exist otherwise testing will fail.
   480  //func (endpoint *Endpoint) GetClientState() exported.ClientState {
   481  //	return endpoint.Chain.GetClientState(endpoint.ClientID)
   482  //}
   483  //
   484  //// SetClientState sets the client state for this endpoint.
   485  //func (endpoint *Endpoint) SetClientState(clientState exported.ClientState) {
   486  //	endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientState(endpoint.Chain.GetContext(), endpoint.ClientID, clientState)
   487  //}
   488  //
   489  //// GetConsensusState retrieves the Consensus State for this endpoint at the provided height.
   490  //// The consensus state is expected to exist otherwise testing will fail.
   491  //func (endpoint *Endpoint) GetConsensusState(height exported.Height) exported.ConsensusState {
   492  //	consensusState, found := endpoint.Chain.GetConsensusState(endpoint.ClientID, height)
   493  //	require.True(endpoint.Chain.t, found)
   494  //
   495  //	return consensusState
   496  //}
   497  //
   498  //// SetConsensusState sets the consensus state for this endpoint.
   499  //func (endpoint *Endpoint) SetConsensusState(consensusState exported.ConsensusState, height exported.Height) {
   500  //	endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(endpoint.Chain.GetContext(), endpoint.ClientID, height, consensusState)
   501  //}
   502  //
   503  //// GetConnection retrieves an IBC Connection for the endpoint. The
   504  //// connection is expected to exist otherwise testing will fail.
   505  //func (endpoint *Endpoint) GetConnection() connectiontypes.ConnectionEnd {
   506  //	connection, found := endpoint.Chain.App.GetIBCKeeper().ConnectionKeeper.GetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID)
   507  //	require.True(endpoint.Chain.t, found)
   508  //
   509  //	return connection
   510  //}
   511  //
   512  //// SetConnection sets the connection for this endpoint.
   513  //func (endpoint *Endpoint) SetConnection(connection connectiontypes.ConnectionEnd) {
   514  //	endpoint.Chain.App.GetIBCKeeper().ConnectionKeeper.SetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID, connection)
   515  //}
   516  //
   517  //// GetChannel retrieves an IBC Channel for the endpoint. The channel
   518  //// is expected to exist otherwise testing will fail.
   519  //func (endpoint *Endpoint) GetChannel() channeltypes.Channel {
   520  //	channel, found := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID)
   521  //	require.True(endpoint.Chain.t, found)
   522  //
   523  //	return channel
   524  //}
   525  //
   526  //// SetChannel sets the channel for this endpoint.
   527  //func (endpoint *Endpoint) SetChannel(channel channeltypes.Channel) {
   528  //	endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel)
   529  //}
   530  //
   531  //// QueryClientStateProof performs and abci query for a client stat associated
   532  //// with this endpoint and returns the ClientState along with the proof.
   533  //func (endpoint *Endpoint) QueryClientStateProof() (exported.ClientState, []byte) {
   534  //	// retrieve client state to provide proof for
   535  //	clientState := endpoint.GetClientState()
   536  //
   537  //	clientKey := host.FullClientStateKey(endpoint.ClientID)
   538  //	proofClient, _ := endpoint.QueryProof(clientKey)
   539  //
   540  //	return clientState, proofClient
   541  //}