refactor: remove .Type() and .Route() from msgs (#14751)

This commit is contained in:
Julien Robert
2023-01-24 17:03:06 +00:00
committed by GitHub
parent bc0386e996
commit 8dbdfea9ef
48 changed files with 409 additions and 769 deletions
-30
View File
@@ -66,16 +66,6 @@ func (msg MsgGrant) ValidateBasic() error {
return msg.Grant.ValidateBasic()
}
// Type implements the LegacyMsg.Type method.
func (msg MsgGrant) Type() string {
return sdk.MsgTypeURL(&msg)
}
// Route implements the LegacyMsg.Route method.
func (msg MsgGrant) Route() string {
return sdk.MsgTypeURL(&msg)
}
// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (msg MsgGrant) GetSignBytes() []byte {
return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg))
@@ -157,16 +147,6 @@ func (msg MsgRevoke) ValidateBasic() error {
return nil
}
// Type implements the LegacyMsg.Type method.
func (msg MsgRevoke) Type() string {
return sdk.MsgTypeURL(&msg)
}
// Route implements the LegacyMsg.Route method.
func (msg MsgRevoke) Route() string {
return sdk.MsgTypeURL(&msg)
}
// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (msg MsgRevoke) GetSignBytes() []byte {
return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg))
@@ -235,16 +215,6 @@ func (msg MsgExec) ValidateBasic() error {
return nil
}
// Type implements the LegacyMsg.Type method.
func (msg MsgExec) Type() string {
return sdk.MsgTypeURL(&msg)
}
// Route implements the LegacyMsg.Route method.
func (msg MsgExec) Route() string {
return sdk.MsgTypeURL(&msg)
}
// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (msg MsgExec) GetSignBytes() []byte {
return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg))
+7 -9
View File
@@ -69,10 +69,11 @@ func (suite *SimTestSuite) TestWeightedOperations() {
expected := []struct {
weight int
opMsgRoute string
opMsgName string
}{
{simulation.WeightGrant, simulation.TypeMsgGrant},
{simulation.WeightExec, simulation.TypeMsgExec},
{simulation.WeightRevoke, simulation.TypeMsgRevoke},
{simulation.WeightGrant, authz.ModuleName, simulation.TypeMsgGrant},
{simulation.WeightExec, authz.ModuleName, simulation.TypeMsgExec},
{simulation.WeightRevoke, authz.ModuleName, simulation.TypeMsgRevoke},
}
require := suite.Require()
@@ -83,12 +84,9 @@ func (suite *SimTestSuite) TestWeightedOperations() {
// the following checks are very much dependent from the ordering of the output given
// by WeightedOperations. if the ordering in WeightedOperations changes some tests
// will fail
require.Equal(expected[i].weight, w.Weight(),
"weight should be the same. %v", op.Comment)
require.Equal(expected[i].opMsgRoute, op.Route,
"route should be the same. %v", op.Comment)
require.Equal(expected[i].opMsgRoute, op.Name,
"operation Msg name should be the same %v", op.Comment)
require.Equal(expected[i].weight, w.Weight(), "weight should be the same. %v", op.Comment)
require.Equal(expected[i].opMsgRoute, op.Route, "route should be the same. %v", op.Comment)
require.Equal(expected[i].opMsgName, op.Name, "operation Msg name should be the same %v", op.Comment)
}
}