From 85e43b57997b0a24af131061b17569440962088e Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 26 May 2023 12:23:19 +0200 Subject: [PATCH 1/2] chore: implement feedback of automerged prs --- x/gov/keeper/proposal_test.go | 14 +++++++------- x/group/keeper/msg_server_test.go | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/x/gov/keeper/proposal_test.go b/x/gov/keeper/proposal_test.go index 0089904264e4..67bb836876a4 100644 --- a/x/gov/keeper/proposal_test.go +++ b/x/gov/keeper/proposal_test.go @@ -89,9 +89,9 @@ func (suite *KeeperTestSuite) TestActivateVotingPeriod() { suite.Require().True(proposal.VotingStartTime.Equal(suite.ctx.BlockHeader().Time)) has, err := suite.govKeeper.ActiveProposalsQueue.Has(suite.ctx, collections.Join(*proposal.VotingEndTime, proposal.Id)) - require.NoError(suite.T(), err) - require.True(suite.T(), has) - require.NoError(suite.T(), suite.govKeeper.DeleteProposal(suite.ctx, proposal.Id)) + suite.Require().NoError(err) + suite.Require().True(has) + suite.Require().NoError(suite.govKeeper.DeleteProposal(suite.ctx, proposal.Id)) } } @@ -111,22 +111,22 @@ func (suite *KeeperTestSuite) TestDeleteProposalInVotingPeriod() { suite.Require().NoError(err) suite.Require().Nil(proposal.VotingStartTime) - require.NoError(suite.T(), suite.govKeeper.ActivateVotingPeriod(suite.ctx, proposal)) + suite.Require().NoError(suite.govKeeper.ActivateVotingPeriod(suite.ctx, proposal)) proposal, err = suite.govKeeper.Proposals.Get(suite.ctx, proposal.Id) suite.Require().Nil(err) suite.Require().True(proposal.VotingStartTime.Equal(suite.ctx.BlockHeader().Time)) has, err := suite.govKeeper.ActiveProposalsQueue.Has(suite.ctx, collections.Join(*proposal.VotingEndTime, proposal.Id)) - require.NoError(suite.T(), err) - require.True(suite.T(), has) + suite.Require().NoError(err) + suite.Require().True(has) // add vote voteOptions := []*v1.WeightedVoteOption{{Option: v1.OptionYes, Weight: "1.0"}} err = suite.govKeeper.AddVote(suite.ctx, proposal.Id, suite.addrs[0], voteOptions, "") suite.Require().NoError(err) - require.NoError(suite.T(), suite.govKeeper.DeleteProposal(suite.ctx, proposal.Id)) + suite.Require().NoError(suite.govKeeper.DeleteProposal(suite.ctx, proposal.Id)) // add vote but proposal is deleted along with its VotingPeriodProposalKey err = suite.govKeeper.AddVote(suite.ctx, proposal.Id, suite.addrs[0], voteOptions, "") diff --git a/x/group/keeper/msg_server_test.go b/x/group/keeper/msg_server_test.go index 78ecc5226b57..9a48f6292bfa 100644 --- a/x/group/keeper/msg_server_test.go +++ b/x/group/keeper/msg_server_test.go @@ -23,7 +23,7 @@ import ( minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) -var EventTallyResult = "cosmos.group.v1.EventProposalPruned" +var EventProposalPruned = "cosmos.group.v1.EventProposalPruned" func (s *TestSuite) TestCreateGroupWithLotsOfMembers() { for i := 50; i < 70; i++ { @@ -1834,7 +1834,7 @@ func (s *TestSuite) TestSubmitProposal() { toBalances := s.bankKeeper.GetAllBalances(sdkCtx, addr2) s.Require().Contains(toBalances, sdk.NewInt64Coin("test", 100)) events := sdkCtx.EventManager().ABCIEvents() - s.Require().True(eventTypeFound(events, EventTallyResult)) + s.Require().True(eventTypeFound(events, EventProposalPruned)) }, }, "with try exec, not enough yes votes for proposal to pass": { @@ -1983,7 +1983,7 @@ func (s *TestSuite) TestWithdrawProposal() { s.Require().NoError(s.groupKeeper.TallyProposalsAtVPEnd(ctxVPE)) events := ctxVPE.EventManager().ABCIEvents() - s.Require().True(eventTypeFound(events, EventTallyResult)) + s.Require().True(eventTypeFound(events, EventProposalPruned)) }, }, } @@ -2549,7 +2549,7 @@ func (s *TestSuite) TestExecProposal() { expToBalances: sdk.NewInt64Coin("test", 100), postRun: func(sdkCtx sdk.Context) { events := sdkCtx.EventManager().ABCIEvents() - s.Require().True(eventTypeFound(events, EventTallyResult)) + s.Require().True(eventTypeFound(events, EventProposalPruned)) }, }, "proposal with multiple messages executed when accepted": { @@ -2567,7 +2567,7 @@ func (s *TestSuite) TestExecProposal() { expToBalances: sdk.NewInt64Coin("test", 200), postRun: func(sdkCtx sdk.Context) { events := sdkCtx.EventManager().ABCIEvents() - s.Require().True(eventTypeFound(events, EventTallyResult)) + s.Require().True(eventTypeFound(events, EventProposalPruned)) }, }, "proposal not executed when rejected": { @@ -2580,7 +2580,7 @@ func (s *TestSuite) TestExecProposal() { expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_NOT_RUN, postRun: func(sdkCtx sdk.Context) { events := sdkCtx.EventManager().ABCIEvents() - s.Require().False(eventTypeFound(events, EventTallyResult)) + s.Require().False(eventTypeFound(events, EventProposalPruned)) }, }, "open proposal must not fail": { @@ -2591,7 +2591,7 @@ func (s *TestSuite) TestExecProposal() { expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_NOT_RUN, postRun: func(sdkCtx sdk.Context) { events := sdkCtx.EventManager().ABCIEvents() - s.Require().False(eventTypeFound(events, EventTallyResult)) + s.Require().False(eventTypeFound(events, EventProposalPruned)) }, }, "invalid proposal id": { @@ -2649,7 +2649,7 @@ func (s *TestSuite) TestExecProposal() { expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_SUCCESS, postRun: func(sdkCtx sdk.Context) { events := sdkCtx.EventManager().ABCIEvents() - s.Require().True(eventTypeFound(events, EventTallyResult)) + s.Require().True(eventTypeFound(events, EventProposalPruned)) }, }, "prevent double execution when successful": { @@ -2939,7 +2939,7 @@ func (s *TestSuite) TestExecPrunedProposalsAndVotes() { s.Require().NoError(err) s.Require().Empty(res.GetVotes()) events := sdkCtx.EventManager().ABCIEvents() - s.Require().True(eventTypeFound(events, EventTallyResult)) + s.Require().True(eventTypeFound(events, EventProposalPruned)) } else { // Check that proposal and votes exists From 6467b0b1984a9ad021f4e7e72a98345b279090c0 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 26 May 2023 12:26:38 +0200 Subject: [PATCH 2/2] re-gen --- api/cosmos/group/v1/events.pulsar.go | 4 ++-- x/group/events.pb.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/cosmos/group/v1/events.pulsar.go b/api/cosmos/group/v1/events.pulsar.go index f800c7d979b5..deebbe181739 100644 --- a/api/cosmos/group/v1/events.pulsar.go +++ b/api/cosmos/group/v1/events.pulsar.go @@ -4763,7 +4763,7 @@ func (x *EventLeaveGroup) GetAddress() string { return "" } -// EventProposalTallyFinalized is an event emitted when a proposal tally is finalized. +// EventProposalPruned is an event emitted when a proposal is pruned. type EventProposalPruned struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -4773,7 +4773,7 @@ type EventProposalPruned struct { ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` // status is the proposal status (UNSPECIFIED, SUBMITTED, ACCEPTED, REJECTED, ABORTED, WITHDRAWN). Status ProposalStatus `protobuf:"varint,2,opt,name=status,proto3,enum=cosmos.group.v1.ProposalStatus" json:"status,omitempty"` - // tally_result is the proposal tally result. + // tally_result is the proposal tally result (when applicable). TallyResult *TallyResult `protobuf:"bytes,3,opt,name=tally_result,json=tallyResult,proto3" json:"tally_result,omitempty"` } diff --git a/x/group/events.pb.go b/x/group/events.pb.go index 9654898cbe2d..dc869b695c66 100644 --- a/x/group/events.pb.go +++ b/x/group/events.pb.go @@ -464,13 +464,13 @@ func (m *EventLeaveGroup) GetAddress() string { return "" } -// EventProposalTallyFinalized is an event emitted when a proposal tally is finalized. +// EventProposalPruned is an event emitted when a proposal is pruned. type EventProposalPruned struct { // proposal_id is the unique ID of the proposal. ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` // status is the proposal status (UNSPECIFIED, SUBMITTED, ACCEPTED, REJECTED, ABORTED, WITHDRAWN). Status ProposalStatus `protobuf:"varint,2,opt,name=status,proto3,enum=cosmos.group.v1.ProposalStatus" json:"status,omitempty"` - // tally_result is the proposal tally result. + // tally_result is the proposal tally result (when applicable). TallyResult *TallyResult `protobuf:"bytes,3,opt,name=tally_result,json=tallyResult,proto3" json:"tally_result,omitempty"` }