From 915caf4b33f63c15dba18c25e1036d955fef87bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rich=CE=9Brd?= Date: Mon, 30 Mar 2020 11:54:08 -0400 Subject: [PATCH] fix: contract does not own itself, and correct min participation calculation (#10) --- contracts/StakingPoolDAO.sol | 3 +-- test/stakingPoolDAO_spec.js | 29 +++-------------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/contracts/StakingPoolDAO.sol b/contracts/StakingPoolDAO.sol index 5cf42cf..6e4f1d9 100644 --- a/contracts/StakingPoolDAO.sol +++ b/contracts/StakingPoolDAO.sol @@ -40,7 +40,6 @@ contract StakingPoolDAO is StakingPool, GSNRecipient, ERC20Snapshot, Controlled constructor (address _tokenAddress, uint _stakingPeriodLen, uint _proposalVoteLength, uint _proposalExpirationLength, uint _minimumParticipation) public StakingPool(_tokenAddress, _stakingPeriodLen) { - changeController(address(uint160(address(this)))); proposalVoteLength = _proposalVoteLength; proposalExpirationLength = _proposalExpirationLength; minimumParticipation = _minimumParticipation; @@ -147,7 +146,7 @@ contract StakingPoolDAO is StakingPool, GSNRecipient, ERC20Snapshot, Controlled require(block.number <= proposal.voteEndingBlock + proposalExpirationLength, "Proposal is already expired"); require(proposal.votes[true] > proposal.votes[false], "Proposal wasn't approved"); - uint totalParticipation = ((proposal.votes[true] + proposal.votes[false]) * 100) / totalSupply(); + uint totalParticipation = ((proposal.votes[true] + proposal.votes[false]) * 10000) / totalSupply(); require(totalParticipation >= minimumParticipation, "Did not meet the minimum required participation"); diff --git a/test/stakingPoolDAO_spec.js b/test/stakingPoolDAO_spec.js index 638a303..0870156 100644 --- a/test/stakingPoolDAO_spec.js +++ b/test/stakingPoolDAO_spec.js @@ -80,13 +80,6 @@ contract("StakingPoolDAO", function () { } }) - describe("contract functionality", () => { - it("contract should be owned by itself", async () => { - const controller = await StakingPool.methods.controller().call(); - assert.strictEqual(controller, StakingPool.options.address); - }); - }); - describe("proposal creation", () => { it("non token holders can not submit proposals", async () => { const toSend = StakingPool.methods.addProposal(andre, 1, "0x", "0x"); @@ -268,26 +261,10 @@ contract("StakingPoolDAO", function () { assert.strictEqual(finalBalance, "12345"); }); - it("set minimum participation", async () => { - // Change minimum participation - const encodedCall = StakingPool.methods.setMinimumParticipation("5000").encodeABI(); - const receipt = await StakingPool.methods.addProposal(StakingPool.options.address, 0, encodedCall, "0x").send({from: richard}); - proposalId = receipt.events.NewProposal.returnValues.proposalId; - - await StakingPool.methods.vote(proposalId, true).send({from: richard}); - - // Mine 20 blocks - for(let i = 0; i < 20; i++){ - await mineAtTimestamp(12345678); - } - - await StakingPool.methods.executeTransaction(proposalId).send({from: iuri}); - - const minimumParticipation = await StakingPool.methods.minimumParticipation().call(); - assert.strictEqual(minimumParticipation, "5000"); - }); - it("requires a minimum participation to execute a proposal", async () => { + // Change minimum participation + await StakingPool.methods.setMinimumParticipation("5000").send(); + const encodedCall = SNT.methods.transfer("0xAA000000000000000000000000000000000000BB", "12345").encodeABI(); const receipt = await StakingPool.methods.addProposal(SNT.options.address, 0, encodedCall, "0x").send({from: richard}); proposalId = receipt.events.NewProposal.returnValues.proposalId;