diff --git a/contracts/VotingMachines/GenesisProtocol.sol b/contracts/VotingMachines/GenesisProtocol.sol index dd207acc..749c6060 100644 --- a/contracts/VotingMachines/GenesisProtocol.sol +++ b/contracts/VotingMachines/GenesisProtocol.sol @@ -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; } @@ -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; } diff --git a/package-lock.json b/package-lock.json index 800dc8cd..215eea65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.0-alpha.47", + "version": "0.0.0-alpha.48", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e1199ae3..4dfba9c1 100644 --- a/package.json +++ b/package.json @@ -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/", diff --git a/test/genesisprotocol.js b/test/genesisprotocol.js index 16c6cd2f..d5154740 100644 --- a/test/genesisprotocol.js +++ b/test/genesisprotocol.js @@ -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); + + }); + + });