Skip to content

Commit

Permalink
Voting: fix bug with required support
Browse files Browse the repository at this point in the history
Address PR aragon#458 comments.
  • Loading branch information
ßingen committed Sep 18, 2018
1 parent bbce73d commit 7571bd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/voting/contracts/Voting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ contract Voting is IForwarder, AragonApp {
}

// Voting is already decided
if (_isValuePct(vote_.yea, vote_.totalVoters, supportRequiredPct)) {
if (_isValuePct(vote_.yea, vote_.totalVoters, vote_.supportRequiredPct)) {
return true;
}

Expand All @@ -207,7 +207,7 @@ contract Voting is IForwarder, AragonApp {
return false;
}
// Has enough support?
if (!_isValuePct(vote_.yea, totalVotes, supportRequiredPct)) {
if (!_isValuePct(vote_.yea, totalVotes, vote_.supportRequiredPct)) {
return false;
}
// Has min quorum?
Expand Down
10 changes: 5 additions & 5 deletions apps/voting/test/voting.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ contract('Voting App', accounts => {
assert.equal((await voting.supportRequiredPct()).toString(), neededSupport.add(1).toString(), 'should have changed required support')
})

it('fails changing required supoprt lower than minimum acceptance quorum', async () => {
it('fails changing required support lower than minimum acceptance quorum', async () => {
return assertRevert(async () => {
await voting.changeSupportRequiredPct(minimumAcceptanceQuorum.minus(1))
})
Expand Down Expand Up @@ -225,12 +225,13 @@ contract('Voting App', accounts => {
// with new quorum at 70% it shouldn't have, but since min quorum is snapshotted
// it will succeed

await voting.vote(voteId, true, true, { from: holder50 })
await voting.vote(voteId, true, true, { from: holder19 })
await voting.vote(voteId, true, false, { from: holder50 })
await voting.vote(voteId, true, false, { from: holder19 })
await voting.vote(voteId, false, false, { from: holder31 })
await timeTravel(votingTime + 1)

const state = await voting.getVote(voteId)
assert.equal(state[5].toNumber(), neededSupport.toNumber(), 'required support in vote should stay equal')
assert.equal(state[5].toNumber(), neededSupport.toNumber(), 'required support in vote should stay equal')
await voting.executeVote(voteId) // exec doesn't fail
})

Expand All @@ -241,7 +242,6 @@ contract('Voting App', accounts => {
// with new quorum at 50% it shouldn't have, but since min quorum is snapshotted
// it will succeed


await voting.vote(voteId, true, true, { from: holder31 })
await timeTravel(votingTime + 1)

Expand Down

0 comments on commit 7571bd0

Please sign in to comment.