Skip to content

Commit

Permalink
GenesisProtocol : Fix quite window period when the proposal direction…
Browse files Browse the repository at this point in the history
… toggles twice (#515)

* GenesisProtocol fix quiteEndPeriod

* Fix test

* bump version to alpha.48
  • Loading branch information
orenyodfat authored Aug 7, 2018
1 parent 5d564a8 commit 20ffd32
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
6 changes: 3 additions & 3 deletions contracts/VotingMachines/GenesisProtocol.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ contract GenesisProtocol is IntVoteInterface,UniversalScheme {
proposal.winningVote = NO;
proposal.paramsHash = paramsHash;
proposals[proposalId] = proposal;
emit NewProposal(proposalId, _avatar, _numOfChoices, msg.sender, paramsHash);
emit NewProposal(proposalId, _avatar, _numOfChoices, _proposer, paramsHash);
return proposalId;
}

Expand Down Expand Up @@ -899,13 +899,13 @@ contract GenesisProtocol is IntVoteInterface,UniversalScheme {
if ((proposal.state == ProposalState.QuietEndingPeriod) ||
((proposal.state == ProposalState.Boosted) && ((_now - proposal.boostedPhaseTime) >= (params.boostedVotePeriodLimit - params.quietEndingPeriod)))) {
//quietEndingPeriod
proposalsExpiredTimes[proposal.avatar].remove(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
if (proposal.state != ProposalState.QuietEndingPeriod) {
proposalsExpiredTimes[proposal.avatar].remove(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
proposal.currentBoostedVotePeriodLimit = params.quietEndingPeriod;
proposalsExpiredTimes[proposal.avatar].insert(_now + proposal.currentBoostedVotePeriodLimit);
proposal.state = ProposalState.QuietEndingPeriod;
}
proposal.boostedPhaseTime = _now;
proposalsExpiredTimes[proposal.avatar].insert(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
}
proposal.winningVote = _vote;
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@daostack/arc",
"version": "0.0.0-alpha.47",
"version": "0.0.0-alpha.48",
"description": "A platform for building DAOs",
"files": [
"contracts/",
Expand Down
28 changes: 28 additions & 0 deletions test/genesisprotocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -1533,4 +1533,32 @@ contract('GenesisProtocol', function (accounts) {

});

it("quite window double toggling direction", async () => {
var quietEndingPeriod = 60;

var testSetup = await setup(accounts,50,60,60,1,1,0,quietEndingPeriod,60,1,10,10,0,15,10);
let tx = await testSetup.genesisProtocol.propose(2, 0, testSetup.org.avatar.address, testSetup.executable.address,accounts[0]);
var proposalId = await getValueFromLogs(tx, '_proposalId');
assert.isOk(proposalId);
//boost proposal
await stake(testSetup,proposalId,1,100,accounts[0]);
assert.equal(await testSetup.genesisProtocol.shouldBoost(proposalId),true);
var proposalInfo = await testSetup.genesisProtocol.proposals(proposalId);
assert.equal(proposalInfo[8],4);//boosted
//vote YES to get in quite window period
await testSetup.genesisProtocol.vote(proposalId,1,{from:accounts[0]}); //change winning vote
proposalInfo = await testSetup.genesisProtocol.proposals(proposalId);
assert.equal(proposalInfo[8],5);//quiteEndperiod
await helpers.increaseTime(10); //increase time
assert.equal(await testSetup.genesisProtocol.orgBoostedProposalsCnt(testSetup.org.avatar.address),1);
//vote NO to toggle direction again and extend the quite end period
await testSetup.genesisProtocol.vote(proposalId,2,{from:accounts[2]}); //change winning vote and execute
assert.equal(await testSetup.genesisProtocol.orgBoostedProposalsCnt(testSetup.org.avatar.address),0);
//increase time after the proposal expiration
await helpers.increaseTime(61); //increase time
assert.equal(await testSetup.genesisProtocol.threshold(testSetup.genesisProtocolParams.paramsHash,testSetup.org.avatar.address),1);

});


});

0 comments on commit 20ffd32

Please sign in to comment.