From 45fdb81dc45ee8d20a748330af05c3bc2994eca6 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 10 Mar 2022 10:25:32 +0100 Subject: [PATCH] fix: handle testing update client errors (#1094) (#1095) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit a7563c9bc03080706788fafcecdf948849187d04) Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- testing/coordinator.go | 6 ++++-- testing/endpoint.go | 18 ++++++++++++------ testing/path.go | 10 +++++++--- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/testing/coordinator.go b/testing/coordinator.go index 5a7a91650fc..65bf5a4f1f3 100644 --- a/testing/coordinator.go +++ b/testing/coordinator.go @@ -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 @@ -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 diff --git a/testing/endpoint.go b/testing/endpoint.go index 5d496494afc..5c2e2e33f4f 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -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() @@ -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() @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/testing/path.go b/testing/path.go index d447102c7b9..731d3cd5e1b 100644 --- a/testing/path.go +++ b/testing/path.go @@ -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 { @@ -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 {