-
Notifications
You must be signed in to change notification settings - Fork 672
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
msg server function and tests for MsgScheduleIBCClientUpgrade #4442
Changes from 1 commit
f9ce4fd
5242278
f499db4
59514fe
55eb017
a4922e7
8c4ca90
70a431f
22125d3
314c81d
b2eee55
2c94f5f
6d7407b
5b4aa3c
5462ba6
f23b9b4
776a7ce
efa5e43
dbbf6b9
eb99d94
77a2720
9744005
7868ed2
d5d5dcb
c418302
4cad828
89da39e
3de8fd5
c92a408
f4cd006
49655cc
0505634
c4c033d
0125cdc
d7ff43a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"errors" | ||
|
||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
|
||
"github.com/cosmos/ibc-go/v7/modules/core/02-client/types" | ||
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" | ||
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" | ||
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" | ||
commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" | ||
host "github.com/cosmos/ibc-go/v7/modules/core/24-host" | ||
ibcerrors "github.com/cosmos/ibc-go/v7/modules/core/errors" | ||
"github.com/cosmos/ibc-go/v7/modules/core/exported" | ||
"github.com/cosmos/ibc-go/v7/modules/core/keeper" | ||
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" | ||
|
@@ -828,6 +833,73 @@ func (suite *KeeperTestSuite) TestUpdateClientParams() { | |
|
||
// TestScheduleIBCClientUpgrade tests the ScheduleIBCClientUpgrade rpc handler | ||
func (suite *KeeperTestSuite) TestScheduleIBCClientUpgrade() { | ||
var ( | ||
expError error | ||
msg *clienttypes.MsgScheduleIBCClientUpgrade | ||
) | ||
testCases := []struct { | ||
name string | ||
malleate func() | ||
expPass bool | ||
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. same as other PR, we can refactor this to be |
||
}{ | ||
{ | ||
"success: valid authority and client upgrade", | ||
func() {}, | ||
true, | ||
}, | ||
{ | ||
"failure: invalid authority address", | ||
func() { | ||
msg.Authority = suite.chainA.SenderAccount.GetAddress().String() | ||
expError = ibcerrors.ErrUnauthorized | ||
}, | ||
false, | ||
}, | ||
{ | ||
"failure: invalid clientState", | ||
func() { | ||
msg.UpgradedClientState = nil | ||
expError = clienttypes.ErrInvalidClientType | ||
}, | ||
false, | ||
}, | ||
{ | ||
"failure: failed to schedule client upgrade", | ||
func() { | ||
msg.Plan.Height = 0 | ||
expError = sdkerrors.ErrInvalidRequest | ||
}, | ||
false, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
suite.Run(tc.name, func() { | ||
suite.SetupTest() | ||
validAuthority := suite.chainA.App.GetIBCKeeper().GetAuthority() | ||
var err error | ||
msg, err = clienttypes.NewMsgScheduleIBCClientUpgrade( | ||
validAuthority, | ||
upgradetypes.Plan{ | ||
Name: "upgrade IBC clients", | ||
Height: 1000, | ||
}, | ||
ibctm.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, types.NewHeight(1, 10), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath), | ||
) | ||
|
||
suite.Require().NoError(err) | ||
|
||
tc.malleate() | ||
|
||
_, err = keeper.Keeper.ScheduleIBCClientUpgrade(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), msg) | ||
if tc.expPass { | ||
suite.Require().NoError(err) | ||
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. Inside |
||
} else { | ||
suite.Require().True(errors.Is(err, expError)) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
// TestUpdateConnectionParams tests the UpdateConnectionParams rpc handler | ||
|
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.
super nit: I like defining the expError on the testCases, it makes it more explicit what we expect to occur and avoids potential mishaps of not setting an expected error