refactor(x/group): check the new admin address when updating the group policy admin (backport #18350) (#18352)
Co-authored-by: Luke Ma <lukema95@gmail.com>
This commit is contained in:
parent
790781009d
commit
f6d4b2e838
@ -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
|
||||
|
||||
@ -661,6 +661,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
|
||||
@ -1215,6 +1224,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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user