Skip to content

Commit

Permalink
fix: Fix group simulations (#11347)
Browse files Browse the repository at this point in the history
## Description

It seems like #10887 broke group simulations, fixing them here.



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
blushi authored Mar 14, 2022
1 parent ec8024e commit 18a8162
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion x/group/keeper/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func GroupTotalWeightInvariantHelper(ctx sdk.Context, key storetypes.StoreKey, g
msg += fmt.Sprintf("error while returning group member iterator for group with ID %d\n%v\n", groupInfo.Id, err)
return msg, broken
}
defer memIt.Close()

for {
_, err = memIt.LoadNext(&groupMember)
Expand All @@ -184,7 +185,6 @@ func GroupTotalWeightInvariantHelper(ctx sdk.Context, key storetypes.StoreKey, g
return msg, broken
}
}
memIt.Close()

groupWeight, err := groupmath.NewNonNegativeDecFromString(groupInfo.GetTotalWeight())
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions x/group/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const (
WeightMsgSubmitProposal = 90
WeightMsgVote = 90
WeightMsgExec = 90
WeightMsgLeaveGroup = 20
WeightMsgLeaveGroup = 5
WeightMsgUpdateGroupMetadata = 5
WeightMsgUpdateGroupAdmin = 5
WeightMsgUpdateGroupMembers = 5
Expand Down Expand Up @@ -188,10 +188,6 @@ func WeightedOperations(
weightMsgCreateGroupPolicy,
SimulateMsgCreateGroupPolicy(ak, bk, k),
),
simulation.NewWeightedOperation(
weightMsgLeaveGroup,
SimulateMsgLeaveGroup(k, ak, bk),
),
simulation.NewWeightedOperation(
weightMsgCreateGroupWithPolicy,
SimulateMsgCreateGroupWithPolicy(ak, bk),
Expand Down Expand Up @@ -235,6 +231,10 @@ func WeightedOperations(
weightMsgUpdateGroupPolicyMetadata,
SimulateMsgUpdateGroupPolicyMetadata(ak, bk, k),
),
simulation.NewWeightedOperation(
weightMsgLeaveGroup,
SimulateMsgLeaveGroup(k, ak, bk),
),
}

return append(wPreCreateProposalOps, append(createProposalOps, wPostCreateProposalOps...)...)
Expand Down
2 changes: 1 addition & 1 deletion x/group/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func (suite *SimTestSuite) TestWeightedOperations() {
}{
{simulation.WeightMsgCreateGroup, group.MsgCreateGroup{}.Route(), simulation.TypeMsgCreateGroup},
{simulation.WeightMsgCreateGroupPolicy, group.MsgCreateGroupPolicy{}.Route(), simulation.TypeMsgCreateGroupPolicy},
{simulation.WeightMsgLeaveGroup, group.MsgLeaveGroup{}.Route(), simulation.TypeMsgLeaveGroup},
{simulation.WeightMsgCreateGroupWithPolicy, group.MsgCreateGroupWithPolicy{}.Route(), simulation.TypeMsgCreateGroupWithPolicy},
{simulation.WeightMsgSubmitProposal, group.MsgSubmitProposal{}.Route(), simulation.TypeMsgSubmitProposal},
{simulation.WeightMsgSubmitProposal, group.MsgSubmitProposal{}.Route(), simulation.TypeMsgSubmitProposal},
Expand All @@ -66,6 +65,7 @@ func (suite *SimTestSuite) TestWeightedOperations() {
{simulation.WeightMsgUpdateGroupPolicyAdmin, group.MsgUpdateGroupPolicyAdmin{}.Route(), simulation.TypeMsgUpdateGroupPolicyAdmin},
{simulation.WeightMsgUpdateGroupPolicyDecisionPolicy, group.MsgUpdateGroupPolicyDecisionPolicy{}.Route(), simulation.TypeMsgUpdateGroupPolicyDecisionPolicy},
{simulation.WeightMsgUpdateGroupPolicyMetadata, group.MsgUpdateGroupPolicyMetadata{}.Route(), simulation.TypeMsgUpdateGroupPolicyMetadata},
{simulation.WeightMsgLeaveGroup, group.MsgLeaveGroup{}.Route(), simulation.TypeMsgLeaveGroup},
}

for i, w := range weightedOps {
Expand Down

0 comments on commit 18a8162

Please sign in to comment.