Skip to content

Commit

Permalink
fix: fix under estimation of undecided count
Browse files Browse the repository at this point in the history
  • Loading branch information
0Tech committed May 27, 2022
1 parent 7de6d34 commit 97bcd3d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion x/foundation/foundation.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (p PercentageDecisionPolicy) Allow(result TallyResult, totalWeight sdk.Dec,
}

totalCounts := result.TotalCounts()
undecided := notAbstaining.Sub(totalCounts)
undecided := totalWeight.Sub(totalCounts)
maxYesCount := result.YesCount.Add(undecided)
maxYesPercentage := maxYesCount.Quo(notAbstaining)
if maxYesPercentage.LT(p.Percentage) {
Expand Down
6 changes: 3 additions & 3 deletions x/foundation/foundation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func TestThresholdDecisionPolicyAllow(t *testing.T) {
},
"deny": {
sinceSubmission: policy.Windows.MinExecutionPeriod,
totalWeight: policy.Threshold,
tally: foundation.NewTallyResult(sdk.ZeroDec(), sdk.ZeroDec(), sdk.OneDec(), sdk.ZeroDec()),
totalWeight: policy.Threshold.Add(sdk.OneDec()),
tally: foundation.NewTallyResult(sdk.ZeroDec(), sdk.OneDec(), sdk.OneDec(), sdk.ZeroDec()),
valid: true,
final: true,
},
Expand Down Expand Up @@ -271,7 +271,7 @@ func TestPercentageDecisionPolicyAllow(t *testing.T) {
},
"not final": {
sinceSubmission: policy.Windows.MinExecutionPeriod,
tally: foundation.NewTallyResult(sdk.NewDec(4), sdk.ZeroDec(), sdk.NewDec(1), sdk.ZeroDec()),
tally: foundation.NewTallyResult(sdk.ZeroDec(), sdk.NewDec(5), sdk.NewDec(1), sdk.ZeroDec()),
valid: true,
},
"deny": {
Expand Down

0 comments on commit 97bcd3d

Please sign in to comment.