fix: contract does not own itself, and correct min participation calculation (#10)

This commit is contained in:
RichΛrd 2020-03-30 11:54:08 -04:00 committed by GitHub
parent 66989c76f3
commit 915caf4b33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 28 deletions

View File

@ -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");

View File

@ -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;