refactor(x/group): check the new admin address when updating the group policy admin (#18350)

This commit is contained in:
Luke Ma
2023-11-03 09:39:58 +00:00
committed by GitHub
parent 0c56c87bd0
commit 457949913d
2 changed files with 30 additions and 0 deletions
+4
View File
@@ -429,6 +429,10 @@ func (k Keeper) UpdateGroupPolicyAdmin(goCtx context.Context, msg *group.MsgUpda
return nil, errorsmod.Wrap(errors.ErrInvalid, "new and old admin are same")
}
if _, err := k.accKeeper.AddressCodec().StringToBytes(msg.NewAdmin); err != nil {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "new admin address")
}
ctx := sdk.UnwrapSDKContext(goCtx)
action := func(groupPolicy *group.GroupPolicyInfo) error {
groupPolicy.Admin = msg.NewAdmin
+26
View File
@@ -663,6 +663,15 @@ func (s *TestSuite) TestUpdateGroupAdmin() {
CreatedAt: s.blockTime,
},
},
"with invalid new admin address": {
req: &group.MsgUpdateGroupAdmin{
GroupId: groupID,
Admin: oldAdmin,
NewAdmin: "%s",
},
expErr: true,
expErrMsg: "new admin address",
},
}
for msg, spec := range specs {
spec := spec
@@ -1217,6 +1226,23 @@ func (s *TestSuite) TestUpdateGroupPolicyAdmin() {
},
expErr: false,
},
"with invalid new admin address": {
req: &group.MsgUpdateGroupPolicyAdmin{
Admin: admin.String(),
GroupPolicyAddress: groupPolicyAddr,
NewAdmin: "%s",
},
expGroupPolicy: &group.GroupPolicyInfo{
Admin: admin.String(),
Address: groupPolicyAddr,
GroupId: myGroupID,
Version: 2,
DecisionPolicy: nil,
CreatedAt: s.blockTime,
},
expErr: true,
expErrMsg: "new admin address",
},
}
for msg, spec := range specs {
spec := spec