Skip to content

Commit

Permalink
fix: pending execution for non-quorum tallies (#420)
Browse files Browse the repository at this point in the history
* pending execution for non-quorum tallies

* test no quorum tally and execute
  • Loading branch information
tkernell authored Nov 4, 2024
1 parent 32fac5f commit 05c3698
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
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

0 comments on commit 05c3698

Please sign in to comment.