Skip to content

Commit c348fbe

Browse files
committed
Fix voteinorganization
1 parent f6cf415 commit c348fbe

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

contracts/schemes/VoteInOrganizationScheme.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ contract VoteInOrganizationScheme is VotingMachineCallbacks, ProposalExecuteInte
106106
{
107107
(uint256 minVote, uint256 maxVote) = _originalIntVote.getAllowedRangeOfChoices();
108108
require(_vote <= maxVote && _vote >= minVote, "vote should be in the allowed range");
109+
require(_vote <= _originalIntVote.getNumberOfChoices(_originalProposalId),
110+
"vote should be <= original proposal number of choices");
109111

110112
bytes32 proposalId = votingMachine.propose(2, voteParamsHash, msg.sender, address(avatar));
111113

test/voteinorganization.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,31 @@ contract('VoteInOrganizationScheme', accounts => {
116116
assert.equal(tx.logs[0].args._vote, 1);
117117
});
118118

119+
it("proposeVote vote not an option", async function() {
120+
var testSetup = await setup(accounts);
121+
122+
var anotherTestSetup = await setup(accounts);
123+
var absoluteVoteExecuteMock = await AbsoluteVoteExecuteMock.new();
124+
await absoluteVoteExecuteMock.initialize(testSetup.org.reputation.address,
125+
anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address);
126+
127+
var tx = await absoluteVoteExecuteMock.propose(2,
128+
anotherTestSetup.voteInOrganizationParams.votingMachine.params,
129+
anotherTestSetup.org.avatar.address,
130+
accounts[0],helpers.NULL_ADDRESS);
131+
132+
const proposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal');
133+
try {
134+
await testSetup.voteInOrganization.proposeVote(
135+
anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address,
136+
proposalId,3,helpers.NULL_HASH
137+
);
138+
assert(false, "vote not an option");
139+
} catch(error) {
140+
helpers.assertVMException(error);
141+
}
142+
});
143+
119144
it("proposeVote vote not in range", async function() {
120145
var standardTokenMock = await ERC20Mock.new(accounts[0],1000);
121146
var testSetup = await setup(accounts,0,true,standardTokenMock.address);

0 commit comments

Comments
 (0)