Skip to content

Commit 20ffd32

Browse files
authored
GenesisProtocol : Fix quite window period when the proposal direction toggles twice (#515)
* GenesisProtocol fix quiteEndPeriod * Fix test * bump version to alpha.48
1 parent 5d564a8 commit 20ffd32

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

contracts/VotingMachines/GenesisProtocol.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ contract GenesisProtocol is IntVoteInterface,UniversalScheme {
156156
proposal.winningVote = NO;
157157
proposal.paramsHash = paramsHash;
158158
proposals[proposalId] = proposal;
159-
emit NewProposal(proposalId, _avatar, _numOfChoices, msg.sender, paramsHash);
159+
emit NewProposal(proposalId, _avatar, _numOfChoices, _proposer, paramsHash);
160160
return proposalId;
161161
}
162162

@@ -899,13 +899,13 @@ contract GenesisProtocol is IntVoteInterface,UniversalScheme {
899899
if ((proposal.state == ProposalState.QuietEndingPeriod) ||
900900
((proposal.state == ProposalState.Boosted) && ((_now - proposal.boostedPhaseTime) >= (params.boostedVotePeriodLimit - params.quietEndingPeriod)))) {
901901
//quietEndingPeriod
902+
proposalsExpiredTimes[proposal.avatar].remove(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
902903
if (proposal.state != ProposalState.QuietEndingPeriod) {
903-
proposalsExpiredTimes[proposal.avatar].remove(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
904904
proposal.currentBoostedVotePeriodLimit = params.quietEndingPeriod;
905-
proposalsExpiredTimes[proposal.avatar].insert(_now + proposal.currentBoostedVotePeriodLimit);
906905
proposal.state = ProposalState.QuietEndingPeriod;
907906
}
908907
proposal.boostedPhaseTime = _now;
908+
proposalsExpiredTimes[proposal.avatar].insert(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
909909
}
910910
proposal.winningVote = _vote;
911911
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@daostack/arc",
3-
"version": "0.0.0-alpha.47",
3+
"version": "0.0.0-alpha.48",
44
"description": "A platform for building DAOs",
55
"files": [
66
"contracts/",

test/genesisprotocol.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,4 +1533,32 @@ contract('GenesisProtocol', function (accounts) {
15331533

15341534
});
15351535

1536+
it("quite window double toggling direction", async () => {
1537+
var quietEndingPeriod = 60;
1538+
1539+
var testSetup = await setup(accounts,50,60,60,1,1,0,quietEndingPeriod,60,1,10,10,0,15,10);
1540+
let tx = await testSetup.genesisProtocol.propose(2, 0, testSetup.org.avatar.address, testSetup.executable.address,accounts[0]);
1541+
var proposalId = await getValueFromLogs(tx, '_proposalId');
1542+
assert.isOk(proposalId);
1543+
//boost proposal
1544+
await stake(testSetup,proposalId,1,100,accounts[0]);
1545+
assert.equal(await testSetup.genesisProtocol.shouldBoost(proposalId),true);
1546+
var proposalInfo = await testSetup.genesisProtocol.proposals(proposalId);
1547+
assert.equal(proposalInfo[8],4);//boosted
1548+
//vote YES to get in quite window period
1549+
await testSetup.genesisProtocol.vote(proposalId,1,{from:accounts[0]}); //change winning vote
1550+
proposalInfo = await testSetup.genesisProtocol.proposals(proposalId);
1551+
assert.equal(proposalInfo[8],5);//quiteEndperiod
1552+
await helpers.increaseTime(10); //increase time
1553+
assert.equal(await testSetup.genesisProtocol.orgBoostedProposalsCnt(testSetup.org.avatar.address),1);
1554+
//vote NO to toggle direction again and extend the quite end period
1555+
await testSetup.genesisProtocol.vote(proposalId,2,{from:accounts[2]}); //change winning vote and execute
1556+
assert.equal(await testSetup.genesisProtocol.orgBoostedProposalsCnt(testSetup.org.avatar.address),0);
1557+
//increase time after the proposal expiration
1558+
await helpers.increaseTime(61); //increase time
1559+
assert.equal(await testSetup.genesisProtocol.threshold(testSetup.genesisProtocolParams.paramsHash,testSetup.org.avatar.address),1);
1560+
1561+
});
1562+
1563+
15361564
});

0 commit comments

Comments
 (0)