-
Notifications
You must be signed in to change notification settings - Fork 629
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
Use counterparty connection hops when verifying channel state #4074
Changes from 4 commits
bd92bfc
ffc3602
c040ef2
0172470
f66eb4b
9ce9b15
ea82872
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -754,6 +754,91 @@ func (suite *KeeperTestSuite) TestChanUpgradeOpen() { | |
} | ||
} | ||
|
||
// TestChanUpgradeOpenCounterPartyStates tests the handshake in the cases where | ||
// the counterparty is in a state other than OPEN. | ||
func (suite *KeeperTestSuite) TestChanUpgradeOpenCounterPartyStates() { | ||
DimitrisJim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var path *ibctesting.Path | ||
testCases := []struct { | ||
name string | ||
malleate func() | ||
expError error | ||
}{ | ||
{ | ||
"success, counterparty in OPEN", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: maybe we could integrate these 2 tests in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ya, this is a tradeoff really, we can add these in the main test but require each test case call the ugprade handshake explicitly or we can separate these. Colin also mentioned how he preferred the separation (ref: #3844 (comment)). I'm open to both options, I think this way it might be slightly cleaner. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would be fine with merging this pr as is :) |
||
func() { | ||
err := path.EndpointB.ChanUpgradeInit() | ||
suite.Require().NoError(err) | ||
|
||
err = path.EndpointA.ChanUpgradeTry() | ||
suite.Require().NoError(err) | ||
|
||
err = path.EndpointB.ChanUpgradeAck() | ||
suite.Require().NoError(err) | ||
|
||
// TODO: Remove when #4030 is closed. Channel will automatically | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. link #4030 |
||
// move to OPEN in that case. | ||
err = path.EndpointB.ChanUpgradeOpen() | ||
suite.Require().NoError(err) | ||
|
||
suite.coordinator.CommitBlock(suite.chainA, suite.chainB) | ||
suite.Require().NoError(path.EndpointA.UpdateClient()) | ||
}, | ||
nil, | ||
}, | ||
{ | ||
"success, counterparty in TRYUPGRADE", | ||
func() { | ||
err := path.EndpointA.ChanUpgradeInit() | ||
suite.Require().NoError(err) | ||
|
||
err = path.EndpointB.ChanUpgradeTry() | ||
suite.Require().NoError(err) | ||
|
||
err = path.EndpointA.ChanUpgradeAck() | ||
suite.Require().NoError(err) | ||
}, | ||
nil, | ||
}, | ||
} | ||
|
||
// Create an initial path used only to invoke a ChanOpenInit handshake. | ||
// This bumps the channel identifier generated for chain A on the | ||
// next path used to run the upgrade handshake. | ||
// See issue 4062. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
path = ibctesting.NewPath(suite.chainA, suite.chainB) | ||
suite.coordinator.SetupClients(path) | ||
suite.Require().NoError(path.EndpointA.ConnOpenInit()) | ||
suite.coordinator.SetupConnections(path) | ||
suite.Require().NoError(path.EndpointA.ChanOpenInit()) | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
suite.Run(tc.name, func() { | ||
suite.SetupTest() | ||
|
||
path = ibctesting.NewPath(suite.chainA, suite.chainB) | ||
suite.coordinator.Setup(path) | ||
|
||
path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion | ||
path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion | ||
|
||
tc.malleate() | ||
|
||
proofCounterpartyChannel, _, proofHeight := path.EndpointA.QueryChannelUpgradeProof() | ||
err := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeOpen( | ||
suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, | ||
path.EndpointB.GetChannel().State, proofCounterpartyChannel, proofHeight, | ||
) | ||
|
||
if tc.expError == nil { | ||
DimitrisJim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
suite.Require().NoError(err) | ||
} else { | ||
suite.Require().ErrorIs(err, tc.expError) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func (suite *KeeperTestSuite) TestChanUpgradeTimeout() { | ||
var ( | ||
path *ibctesting.Path | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linky-link more, opened issue on spec repo to keep track cosmos/ibc#1004