From 36784a8a7a933c8f31930ad6302321be375a8509 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 7 Jan 2023 12:19:18 +0000 Subject: [PATCH] fix: wrong address set in `EventUpdateGroupPolicy` (backport #14526) (#14528) Co-authored-by: Julien Robert --- CHANGELOG.md | 1 + x/group/keeper/keeper_test.go | 22 ++++++++++++++++++++++ x/group/keeper/msg_server.go | 3 +-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21526ee3e3cb..068f02fb5fc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (x/group) [#14526](https://github.com/cosmos/cosmos-sdk/pull/14526) Fix wrong address set in `EventUpdateGroupPolicy`. * (ante) [#14448](https://github.com/cosmos/cosmos-sdk/pull/14448) Return anteEvents when postHandler fail. ### API Breaking diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index 8664dfecddd1..56a748018965 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -438,6 +438,9 @@ func (s *TestSuite) TestUpdateGroupMetadata() { res, err := s.keeper.GroupInfo(ctx, &group.QueryGroupInfoRequest{GroupId: groupID}) s.Require().NoError(err) s.Assert().Equal(spec.expStored, res.Info) + + events := sdkCtx.EventManager().ABCIEvents() + s.Require().Len(events, 1) // EventUpdateGroup }) } } @@ -721,6 +724,9 @@ func (s *TestSuite) TestUpdateGroupMembers() { s.Assert().Equal(spec.expMembers[i].Member.AddedAt, loadedMembers[i].Member.AddedAt) s.Assert().Equal(spec.expMembers[i].GroupId, loadedMembers[i].GroupId) } + + events := sdkCtx.EventManager().ABCIEvents() + s.Require().Len(events, 1) // EventUpdateGroup }) } } @@ -1242,6 +1248,22 @@ func (s *TestSuite) TestUpdateGroupPolicyMetadata() { }) s.Require().NoError(err) s.Assert().Equal(spec.expGroupPolicy, res.Info) + + // check events + var hasUpdateGroupPolicyEvent bool + events := s.ctx.(sdk.Context).EventManager().ABCIEvents() + for _, event := range events { + event, err := sdk.ParseTypedEvent(event) + if err == nil { + if e, ok := event.(*group.EventUpdateGroupPolicy); ok { + s.Require().Equal(e.Address, groupPolicyAddr) + hasUpdateGroupPolicyEvent = true + break + } + } + } + + s.Require().True(hasUpdateGroupPolicyEvent) }) } } diff --git a/x/group/keeper/msg_server.go b/x/group/keeper/msg_server.go index 0023c57a90b4..3947f0adad50 100644 --- a/x/group/keeper/msg_server.go +++ b/x/group/keeper/msg_server.go @@ -911,8 +911,7 @@ func (k Keeper) doUpdateGroupPolicy(ctx sdk.Context, groupPolicy string, admin s return err } - err = ctx.EventManager().EmitTypedEvent(&group.EventUpdateGroupPolicy{Address: admin}) - if err != nil { + if err = ctx.EventManager().EmitTypedEvent(&group.EventUpdateGroupPolicy{Address: groupPolicyInfo.Address}); err != nil { return err }