Skip to content

Commit 45fdb81

Browse files
fix: handle testing update client errors (#1094) (#1095)
(cherry picked from commit a7563c9) Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
1 parent 549d9bf commit 45fdb81

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

testing/coordinator.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ func (coord *Coordinator) CreateConnections(path *Path) {
117117
require.NoError(coord.T, err)
118118

119119
// ensure counterparty is up to date
120-
path.EndpointA.UpdateClient()
120+
err = path.EndpointA.UpdateClient()
121+
require.NoError(coord.T, err)
121122
}
122123

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

160161
// ensure counterparty is up to date
161-
path.EndpointA.UpdateClient()
162+
err = path.EndpointA.UpdateClient()
163+
require.NoError(coord.T, err)
162164
}
163165

164166
// GetChain returns the TestChain using the given chainID and returns an error if it does

testing/endpoint.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ func (endpoint *Endpoint) ConnOpenInit() error {
175175

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

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

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

203204
// ConnOpenAck will construct and execute a MsgConnectionOpenAck on the associated endpoint.
204205
func (endpoint *Endpoint) ConnOpenAck() error {
205-
endpoint.UpdateClient()
206+
err := endpoint.UpdateClient()
207+
require.NoError(endpoint.Chain.T, err)
206208

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

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

219221
// ConnOpenConfirm will construct and execute a MsgConnectionOpenConfirm on the associated endpoint.
220222
func (endpoint *Endpoint) ConnOpenConfirm() error {
221-
endpoint.UpdateClient()
223+
err := endpoint.UpdateClient()
224+
require.NoError(endpoint.Chain.T, err)
222225

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

282285
// ChanOpenTry will construct and execute a MsgChannelOpenTry on the associated endpoint.
283286
func (endpoint *Endpoint) ChanOpenTry() error {
284-
endpoint.UpdateClient()
287+
err := endpoint.UpdateClient()
288+
require.NoError(endpoint.Chain.T, err)
285289

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

313317
// ChanOpenAck will construct and execute a MsgChannelOpenAck on the associated endpoint.
314318
func (endpoint *Endpoint) ChanOpenAck() error {
315-
endpoint.UpdateClient()
319+
err := endpoint.UpdateClient()
320+
require.NoError(endpoint.Chain.T, err)
316321

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

329334
// ChanOpenConfirm will construct and execute a MsgChannelOpenConfirm on the associated endpoint.
330335
func (endpoint *Endpoint) ChanOpenConfirm() error {
331-
endpoint.UpdateClient()
336+
err := endpoint.UpdateClient()
337+
require.NoError(endpoint.Chain.T, err)
332338

333339
channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID)
334340
proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey)

testing/path.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ func (path *Path) RelayPacket(packet channeltypes.Packet) error {
4343
if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointA.Chain.App.AppCodec(), packet)) {
4444

4545
// packet found, relay from A to B
46-
path.EndpointB.UpdateClient()
46+
if err := path.EndpointB.UpdateClient(); err != nil {
47+
return err
48+
}
4749

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

64+
return nil
6365
}
6466

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

6870
// packet found, relay B to A
69-
path.EndpointA.UpdateClient()
71+
if err := path.EndpointA.UpdateClient(); err != nil {
72+
return err
73+
}
7074

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

0 commit comments

Comments
 (0)