Skip to content

Commit

Permalink
fix: wrong address set in EventUpdateGroupPolicy (backport cosmos#1…
Browse files Browse the repository at this point in the history
…4526) (cosmos#14528)

Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
2 people authored and jiujiteiro committed Mar 7, 2023
1 parent f134bc1 commit f230c2f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions x/group/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
}
Expand Down Expand Up @@ -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
})
}
}
Expand Down Expand Up @@ -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)
})
}
}
Expand Down
3 changes: 1 addition & 2 deletions x/group/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit f230c2f

Please sign in to comment.