Skip to content

Commit

Permalink
fix: handle testing update client errors (#1094)
Browse files Browse the repository at this point in the history
(cherry picked from commit a7563c9)
  • Loading branch information
fedekunze authored and mergify-bot committed Mar 9, 2022
1 parent 549d9bf commit bb74101
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
6 changes: 4 additions & 2 deletions testing/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ func (coord *Coordinator) CreateConnections(path *Path) {
require.NoError(coord.T, err)

// ensure counterparty is up to date
path.EndpointA.UpdateClient()
err = path.EndpointA.UpdateClient()
require.NoError(coord.T, err)
}

// CreateMockChannels constructs and executes channel handshake messages to create OPEN
Expand Down Expand Up @@ -158,7 +159,8 @@ func (coord *Coordinator) CreateChannels(path *Path) {
require.NoError(coord.T, err)

// ensure counterparty is up to date
path.EndpointA.UpdateClient()
err = path.EndpointA.UpdateClient()
require.NoError(coord.T, err)
}

// GetChain returns the TestChain using the given chainID and returns an error if it does
Expand Down
18 changes: 12 additions & 6 deletions testing/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ func (endpoint *Endpoint) ConnOpenInit() error {

// ConnOpenTry will construct and execute a MsgConnectionOpenTry on the associated endpoint.
func (endpoint *Endpoint) ConnOpenTry() error {
endpoint.UpdateClient()
err := endpoint.UpdateClient()
require.NoError(endpoint.Chain.T, err)

counterpartyClient, proofClient, proofConsensus, consensusHeight, proofInit, proofHeight := endpoint.QueryConnectionHandshakeProof()

Expand All @@ -202,7 +203,8 @@ func (endpoint *Endpoint) ConnOpenTry() error {

// ConnOpenAck will construct and execute a MsgConnectionOpenAck on the associated endpoint.
func (endpoint *Endpoint) ConnOpenAck() error {
endpoint.UpdateClient()
err := endpoint.UpdateClient()
require.NoError(endpoint.Chain.T, err)

counterpartyClient, proofClient, proofConsensus, consensusHeight, proofTry, proofHeight := endpoint.QueryConnectionHandshakeProof()

Expand All @@ -218,7 +220,8 @@ func (endpoint *Endpoint) ConnOpenAck() error {

// ConnOpenConfirm will construct and execute a MsgConnectionOpenConfirm on the associated endpoint.
func (endpoint *Endpoint) ConnOpenConfirm() error {
endpoint.UpdateClient()
err := endpoint.UpdateClient()
require.NoError(endpoint.Chain.T, err)

connectionKey := host.ConnectionKey(endpoint.Counterparty.ConnectionID)
proof, height := endpoint.Counterparty.Chain.QueryProof(connectionKey)
Expand Down Expand Up @@ -281,7 +284,8 @@ func (endpoint *Endpoint) ChanOpenInit() error {

// ChanOpenTry will construct and execute a MsgChannelOpenTry on the associated endpoint.
func (endpoint *Endpoint) ChanOpenTry() error {
endpoint.UpdateClient()
err := endpoint.UpdateClient()
require.NoError(endpoint.Chain.T, err)

channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID)
proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey)
Expand Down Expand Up @@ -312,7 +316,8 @@ func (endpoint *Endpoint) ChanOpenTry() error {

// ChanOpenAck will construct and execute a MsgChannelOpenAck on the associated endpoint.
func (endpoint *Endpoint) ChanOpenAck() error {
endpoint.UpdateClient()
err := endpoint.UpdateClient()
require.NoError(endpoint.Chain.T, err)

channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID)
proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey)
Expand All @@ -328,7 +333,8 @@ func (endpoint *Endpoint) ChanOpenAck() error {

// ChanOpenConfirm will construct and execute a MsgChannelOpenConfirm on the associated endpoint.
func (endpoint *Endpoint) ChanOpenConfirm() error {
endpoint.UpdateClient()
err := endpoint.UpdateClient()
require.NoError(endpoint.Chain.T, err)

channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID)
proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey)
Expand Down
10 changes: 7 additions & 3 deletions testing/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func (path *Path) RelayPacket(packet channeltypes.Packet) error {
if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointA.Chain.App.AppCodec(), packet)) {

// packet found, relay from A to B
path.EndpointB.UpdateClient()
if err := path.EndpointB.UpdateClient(); err != nil {
return err
}

res, err := path.EndpointB.RecvPacketWithResult(packet)
if err != nil {
Expand All @@ -58,15 +60,17 @@ func (path *Path) RelayPacket(packet channeltypes.Packet) error {
if err := path.EndpointA.AcknowledgePacket(packet, ack); err != nil {
return err
}
return nil

return nil
}

pc = path.EndpointB.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointB.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointB.Chain.App.AppCodec(), packet)) {

// packet found, relay B to A
path.EndpointA.UpdateClient()
if err := path.EndpointA.UpdateClient(); err != nil {
return err
}

res, err := path.EndpointA.RecvPacketWithResult(packet)
if err != nil {
Expand Down

0 comments on commit bb74101

Please sign in to comment.