-
Notifications
You must be signed in to change notification settings - Fork 586
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
chore: refactor chanUpgradeAck
tests to use expected errors
#3843
Changes from 6 commits
aa63a78
a1832c9
ee83776
34abbab
049d152
6dca87c
16dd59e
b3fa37c
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 |
---|---|---|
|
@@ -335,12 +335,12 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { | |
testCases := []struct { | ||
name string | ||
malleate func() | ||
expPass bool | ||
expError error | ||
}{ | ||
{ | ||
"success", | ||
func() {}, | ||
true, | ||
nil, | ||
}, | ||
{ | ||
"success with later upgrade sequence", | ||
|
@@ -358,29 +358,29 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { | |
err := path.EndpointA.UpdateClient() | ||
suite.Require().NoError(err) | ||
}, | ||
true, | ||
nil, | ||
}, | ||
{ | ||
"channel not found", | ||
func() { | ||
path.EndpointA.ChannelID = ibctesting.InvalidID | ||
path.EndpointA.ChannelConfig.PortID = ibctesting.InvalidID | ||
}, | ||
false, | ||
types.ErrChannelNotFound, | ||
}, | ||
{ | ||
"channel state is not in INITUPGRADE or TRYUPGRADE state", | ||
func() { | ||
suite.Require().NoError(path.EndpointA.SetChannelState(types.CLOSED)) | ||
}, | ||
false, | ||
types.ErrInvalidChannelState, | ||
}, | ||
{ | ||
"counterparty flush status is not in FLUSHING or FLUSHCOMPLETE", | ||
func() { | ||
counterpartyFlushStatus = types.NOTINFLUSH | ||
}, | ||
false, | ||
types.ErrInvalidFlushStatus, | ||
}, | ||
{ | ||
"connection not found", | ||
|
@@ -389,7 +389,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { | |
channel.ConnectionHops = []string{"connection-100"} | ||
path.EndpointA.SetChannel(channel) | ||
}, | ||
false, | ||
connectiontypes.ErrConnectionNotFound, | ||
}, | ||
{ | ||
"invalid connection state", | ||
|
@@ -398,46 +398,47 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { | |
connectionEnd.State = connectiontypes.UNINITIALIZED | ||
path.EndpointA.SetConnection(connectionEnd) | ||
}, | ||
false, | ||
connectiontypes.ErrInvalidConnectionState, | ||
}, | ||
{ | ||
"upgrade not found", | ||
func() { | ||
store := suite.chainA.GetContext().KVStore(suite.chainA.GetSimApp().GetKey(exported.ModuleName)) | ||
store.Delete(host.ChannelUpgradeKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) | ||
}, | ||
false, | ||
types.ErrUpgradeNotFound, | ||
}, | ||
{ | ||
"channel end version mismatch on crossing hellos", | ||
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. moved to bottom as this is last in the call stack |
||
"startFlushUpgradeHandshake fails due to proof verification failure, counterparty upgrade connection hops are tampered with", | ||
func() { | ||
channel := path.EndpointA.GetChannel() | ||
channel.State = types.TRYUPGRADE | ||
|
||
path.EndpointA.SetChannel(channel) | ||
|
||
upgrade := path.EndpointA.GetChannelUpgrade() | ||
upgrade.Fields.Version = "invalid-version" | ||
|
||
path.EndpointA.SetChannelUpgrade(upgrade) | ||
counterpartyUpgrade.Fields.ConnectionHops = []string{ibctesting.InvalidID} | ||
}, | ||
false, | ||
commitmenttypes.ErrInvalidProof, | ||
}, | ||
{ | ||
"startFlushUpgradeHandshake fails due to proof verification failure, counterparty upgrade connection hops are tampered with", | ||
"startFlushUpgradeHandshake fails due to mismatch in upgrade ordering", | ||
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 changed this testcase from: This was the one testcase which was actually failing on proof verification before we got to the checks afterwards. |
||
func() { | ||
counterpartyUpgrade.Fields.ConnectionHops = []string{ibctesting.InvalidID} | ||
upgrade := path.EndpointA.GetChannelUpgrade() | ||
upgrade.Fields.Ordering = types.NONE | ||
|
||
path.EndpointA.SetChannelUpgrade(upgrade) | ||
}, | ||
false, | ||
types.NewUpgradeError(1, types.ErrIncompatibleCounterpartyUpgrade), | ||
}, | ||
{ | ||
"startFlushUpgradeHandshake fails due to mismatch in upgrade sequences", | ||
"channel end version mismatch on crossing hellos", | ||
func() { | ||
channel := path.EndpointA.GetChannel() | ||
channel.UpgradeSequence = 5 | ||
channel.State = types.TRYUPGRADE | ||
|
||
path.EndpointA.SetChannel(channel) | ||
|
||
upgrade := path.EndpointA.GetChannelUpgrade() | ||
upgrade.Fields.Version = "invalid-version" | ||
|
||
path.EndpointA.SetChannelUpgrade(upgrade) | ||
}, | ||
false, | ||
types.NewUpgradeError(1, types.ErrIncompatibleCounterpartyUpgrade), | ||
}, | ||
} | ||
|
||
|
@@ -475,10 +476,11 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { | |
proofChannel, proofUpgrade, proofHeight, | ||
) | ||
|
||
if tc.expPass { | ||
expPass := tc.expError == nil | ||
if expPass { | ||
suite.Require().NoError(err) | ||
} else { | ||
suite.Require().Error(err) | ||
suite.assertUpgradeError(err, tc.expError) | ||
} | ||
}) | ||
} | ||
|
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.
moved this to below
ChanUpgradeAck