Skip to content

Commit

Permalink
Rename messages to match other modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisJim committed May 31, 2023
1 parent 1cb9375 commit 0364f34
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 151 deletions.
2 changes: 1 addition & 1 deletion e2e/tests/core/03-connection/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() {
s.Require().NoError(err)
s.Require().NotNil(authority)

msg := connectiontypes.NewMsgUpdateConnectionParams(authority.String(), connectiontypes.NewParams(delay))
msg := connectiontypes.NewMsgUpdateParams(authority.String(), connectiontypes.NewParams(delay))
s.ExecuteGovProposalV1(ctx, msg, chainA, chainAWallet, 1)
} else {
changes := []paramsproposaltypes.ParamChange{
Expand Down
4 changes: 2 additions & 2 deletions modules/core/03-connection/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ func (k Keeper) addConnectionToClient(ctx sdk.Context, clientID, connectionID st
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.ParamsKey))
if len(bz) == 0 {
return types.Params{}
if bz == nil { // only panic on unset params and not on empty params
panic("controller params are not set in store")
}

var params types.Params
Expand Down
4 changes: 3 additions & 1 deletion modules/core/03-connection/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,7 @@ func (suite *KeeperTestSuite) TestUnsetParams() {
store := ctx.KVStore(suite.chainA.GetSimApp().GetKey(exported.StoreKey))
store.Delete([]byte(types.ParamsKey))

suite.Require().Equal(suite.chainA.GetSimApp().IBCKeeper.ConnectionKeeper.GetParams(ctx), types.Params{})
suite.Require().Panics(func() {
suite.chainA.GetSimApp().IBCKeeper.ConnectionKeeper.GetParams(ctx)
})
}
2 changes: 1 addition & 1 deletion modules/core/03-connection/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
&MsgConnectionOpenTry{},
&MsgConnectionOpenAck{},
&MsgConnectionOpenConfirm{},
&MsgUpdateConnectionParams{},
&MsgUpdateParams{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
Expand Down
16 changes: 8 additions & 8 deletions modules/core/03-connection/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (
_ sdk.Msg = (*MsgConnectionOpenConfirm)(nil)
_ sdk.Msg = (*MsgConnectionOpenAck)(nil)
_ sdk.Msg = (*MsgConnectionOpenTry)(nil)
_ sdk.Msg = (*MsgUpdateConnectionParams)(nil)
_ sdk.Msg = (*MsgUpdateParams)(nil)

_ codectypes.UnpackInterfacesMessage = (*MsgConnectionOpenTry)(nil)
_ codectypes.UnpackInterfacesMessage = (*MsgConnectionOpenAck)(nil)
Expand Down Expand Up @@ -291,25 +291,25 @@ func (msg MsgConnectionOpenConfirm) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{accAddr}
}

// NewMsgUpdateConnectionParams creates a new MsgUpdateConnectionParams instance
func NewMsgUpdateConnectionParams(authority string, params Params) *MsgUpdateConnectionParams {
return &MsgUpdateConnectionParams{
// NewMsgUpdateParams creates a new MsgUpdateParams instance
func NewMsgUpdateParams(authority string, params Params) *MsgUpdateParams {
return &MsgUpdateParams{
Authority: authority,
Params: params,
}
}

// GetSigners returns the expected signers for a MsgUpdateConnectionParams message.
func (msg *MsgUpdateConnectionParams) GetSigners() []sdk.AccAddress {
// GetSigners returns the expected signers for a MsgUpdateParams message.
func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress {
accAddr, err := sdk.AccAddressFromBech32(msg.Authority)
if err != nil {
panic(err)
}
return []sdk.AccAddress{accAddr}
}

// ValidateBasic performs basic checks on a MsgUpdateConnectionParams.
func (msg *MsgUpdateConnectionParams) ValidateBasic() error {
// ValidateBasic performs basic checks on a MsgUpdateParams.
func (msg *MsgUpdateParams) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err)
}
Expand Down
12 changes: 6 additions & 6 deletions modules/core/03-connection/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,27 +232,27 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() {
}
}

// TestMsgUpdateConnectionParams_ValidateBasic tests ValidateBasic for MsgUpdateConnectionParams
func (suite *MsgTestSuite) TestMsgUpdateConnectionParams_ValidateBasic() {
// TestMsgUpdateParams_ValidateBasic tests ValidateBasic for MsgUpdateParams
func (suite *MsgTestSuite) TestMsgUpdateParams_ValidateBasic() {
authority := suite.chainA.App.GetIBCKeeper().GetAuthority()
testCases := []struct {
name string
msg *types.MsgUpdateConnectionParams
msg *types.MsgUpdateParams
expPass bool
}{
{
"success: valid authority and params",
types.NewMsgUpdateConnectionParams(authority, types.DefaultParams()),
types.NewMsgUpdateParams(authority, types.DefaultParams()),
true,
},
{
"failure: invalid authority address",
types.NewMsgUpdateConnectionParams("invalid", types.DefaultParams()),
types.NewMsgUpdateParams("invalid", types.DefaultParams()),
false,
},
{
"failure: invalid time per block",
types.NewMsgUpdateConnectionParams(authority, types.NewParams(0)),
types.NewMsgUpdateParams(authority, types.NewParams(0)),
false,
},
}
Expand Down
Loading

0 comments on commit 0364f34

Please sign in to comment.