Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle testing update client errors #1094

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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