Skip to content

Commit

Permalink
test: added tests for UpdateChannelParams (cosmos#5494)
Browse files Browse the repository at this point in the history
* test: added tests for UpdateChannelParams

* Add assert on the response.

---------

Co-authored-by: DimitrisJim <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Cian Hatton <[email protected]>
  • Loading branch information
4 people authored Jan 3, 2024
1 parent 5636fa8 commit 6736c09
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions modules/core/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2017,6 +2017,62 @@ func (suite *KeeperTestSuite) TestUpdateConnectionParams() {
}
}

// TestUpdateChannelParams tests the UpdateChannelParams rpc handler
func (suite *KeeperTestSuite) TestUpdateChannelParams() {
authority := suite.chainA.App.GetIBCKeeper().GetAuthority()
testCases := []struct {
name string
msg *channeltypes.MsgUpdateParams
expPass bool
}{
{
"success: valid authority and default params",
channeltypes.NewMsgUpdateChannelParams(authority, channeltypes.DefaultParams()),
true,
},
{
"failure: malformed authority address",
channeltypes.NewMsgUpdateChannelParams(ibctesting.InvalidID, channeltypes.DefaultParams()),
false,
},
{
"failure: empty authority address",
channeltypes.NewMsgUpdateChannelParams("", channeltypes.DefaultParams()),
false,
},
{
"failure: whitespace authority address",
channeltypes.NewMsgUpdateChannelParams(" ", channeltypes.DefaultParams()),
false,
},
{
"failure: unauthorized authority address",
channeltypes.NewMsgUpdateChannelParams(ibctesting.TestAccAddress, channeltypes.DefaultParams()),
false,
},
}

for _, tc := range testCases {
tc := tc
suite.Run(tc.name, func() {
suite.SetupTest()

resp, err := keeper.Keeper.UpdateChannelParams(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), tc.msg)

if tc.expPass {
suite.Require().NoError(err)
suite.Require().NotNil(resp)

p := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetParams(suite.chainA.GetContext())
suite.Require().Equal(tc.msg.Params, p)
} else {
suite.Require().Error(err)
suite.Require().Nil(resp)
}
})
}
}

func (suite *KeeperTestSuite) TestPruneAcknowledgements() {
var msg *channeltypes.MsgPruneAcknowledgements

Expand Down

0 comments on commit 6736c09

Please sign in to comment.