From 513c5f30c2e96f1aef2e351085f87801c98d0c14 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Wed, 13 May 2020 19:26:19 +0200 Subject: [PATCH] Alter connection handshake (#6209) * Alter connection handshake * Add test-case Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> --- x/ibc/03-connection/keeper/handshake.go | 4 ++-- x/ibc/03-connection/keeper/handshake_test.go | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/x/ibc/03-connection/keeper/handshake.go b/x/ibc/03-connection/keeper/handshake.go index 64cac7628b..a1814476cb 100644 --- a/x/ibc/03-connection/keeper/handshake.go +++ b/x/ibc/03-connection/keeper/handshake.go @@ -141,8 +141,8 @@ func (k Keeper) ConnOpenAck( return sdkerrors.Wrap(types.ErrConnectionNotFound, "cannot relay ACK of open attempt") } - // Check connection on ChainA is on correct state: INIT - if connection.State != ibctypes.INIT { + // Check connection on ChainA is on correct state: INIT or TRYOPEN + if connection.State != ibctypes.INIT && connection.State != ibctypes.TRYOPEN { return sdkerrors.Wrapf( types.ErrInvalidConnectionState, "connection state is not INIT (got %s)", connection.State.String(), diff --git a/x/ibc/03-connection/keeper/handshake_test.go b/x/ibc/03-connection/keeper/handshake_test.go index ccd2071f0b..4522f1ea72 100644 --- a/x/ibc/03-connection/keeper/handshake_test.go +++ b/x/ibc/03-connection/keeper/handshake_test.go @@ -156,6 +156,15 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { suite.chainA.updateClient(suite.chainB) return suite.chainB.Header.GetHeight() }, true}, + {"success from tryopen", version, func() uint64 { + suite.chainA.CreateClient(suite.chainB) + suite.chainB.CreateClient(suite.chainA) + suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, ibctypes.TRYOPEN) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.TRYOPEN) + suite.chainB.updateClient(suite.chainA) + suite.chainA.updateClient(suite.chainB) + return suite.chainB.Header.GetHeight() + }, true}, {"consensus height > latest height", version, func() uint64 { return 10 }, false},