Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release/v1.x] fix: pending execution for non-quorum tallies #421

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions tests/integration/dispute_keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,31 @@ func (s *IntegrationTestSuite) TestNoQorumSingleRound() {

_, err = msgServer.Vote(s.Setup.Ctx, &voteMsg)
s.NoError(err)
// forward time to expire dispute
s.Setup.Ctx = s.Setup.Ctx.WithBlockTime(s.Setup.Ctx.BlockTime().Add(keeper.THREE_DAYS + 1))
s.NoError(s.Setup.Disputekeeper.TallyVote(s.Setup.Ctx, 1))
s.NoError(s.Setup.Disputekeeper.ExecuteVote(s.Setup.Ctx, 1))
// forward time to expire dispute and tally vote
s.Setup.Ctx = s.Setup.Ctx.WithBlockTime(s.Setup.Ctx.BlockTime().Add(keeper.TWO_DAYS + 1))
_, err = s.Setup.App.BeginBlocker(s.Setup.Ctx)
s.NoError(err)

voteInfo, err := s.Setup.Disputekeeper.Votes.Get(s.Setup.Ctx, 1)
s.NoError(err)
s.Equal(types.VoteResult_NO_QUORUM_MAJORITY_INVALID, voteInfo.VoteResult)
dispute, err := s.Setup.Disputekeeper.Disputes.Get(s.Setup.Ctx, 1)
s.NoError(err)
s.Equal(types.Unresolved, dispute.DisputeStatus)
s.True(dispute.PendingExecution)
s.False(voteInfo.Executed)

// forward time to execute vote
s.Setup.Ctx = s.Setup.Ctx.WithBlockTime(s.Setup.Ctx.BlockTime().Add(keeper.ONE_DAY + 1))
_, err = s.Setup.App.BeginBlocker(s.Setup.Ctx)
s.NoError(err)
dispute, err = s.Setup.Disputekeeper.Disputes.Get(s.Setup.Ctx, 1)
s.NoError(err)
s.Equal(types.Resolved, dispute.DisputeStatus)
s.False(dispute.PendingExecution)
voteInfo, err = s.Setup.Disputekeeper.Votes.Get(s.Setup.Ctx, 1)
s.NoError(err)
s.True(voteInfo.Executed)
}

func (s *IntegrationTestSuite) TestDisputeButNoVotes() {
Expand Down
2 changes: 1 addition & 1 deletion x/dispute/keeper/tally.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ func (k Keeper) TallyVote(ctx context.Context, id uint64) error {
// quorum not reached case
if vote.VoteEnd.Before(sdkctx.BlockTime()) {
dispute.DisputeStatus = types.Unresolved
dispute.PendingExecution = true
// check if rounds have been exhausted or dispute has expired in order to disperse funds
if dispute.DisputeEndTime.Before(sdkctx.BlockTime()) {
dispute.DisputeStatus = types.Resolved
dispute.Open = false
dispute.PendingExecution = true
}
allvoters, err := k.GetVoters(ctx, id)
if err != nil {
Expand Down
Loading