Skip to content

Commit 7936073

Browse files
authored
competition repchange >=0 (#713)
1 parent 74946b8 commit 7936073

File tree

6 files changed

+49
-18
lines changed

6 files changed

+49
-18
lines changed

contracts/schemes/Competition.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ contract Competition {
9696
/**
9797
* @dev Submit a competion proposal
9898
* @param _descriptionHash A hash of the proposal's description
99-
* @param _reputationChange - Amount of reputation change requested .Can be negative.
99+
* @param _reputationChange - Amount of reputation change requested.
100100
* @param _rewards rewards array:
101101
* rewards[0] - Amount of tokens requested per period
102102
* rewards[1] - Amount of ETH requested per period
@@ -146,7 +146,7 @@ contract Competition {
146146
if (_rewards[2] > 0) {
147147
require(_externalToken != ERC20(0), "extenal token cannot be zero");
148148
}
149-
require(_reputationChange > 0, "only positive rep change(minting) allowed for a competition");
149+
require(_reputationChange >= 0, "negative reputation change is not allowed for a competition");
150150
uint256 totalRewardSplit;
151151
for (uint256 i = 0; i < numberOfWinners; i++) {
152152
totalRewardSplit = totalRewardSplit.add(_rewardSplit[i]);

contracts/schemes/ContributionRewardExt.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ contract ContributionRewardExt is VotingMachineCallbacks, ProposalExecuteInterfa
162162
beneficiary = msg.sender;
163163
}
164164
if (beneficiary == address(this)) {
165-
require(_reputationChange > 0, "only positive rep change(minting) allowed for this case");
165+
require(_reputationChange >= 0, "negative rep change not allowed for this case");
166166
}
167167

168168
ContributionProposal memory proposal = ContributionProposal({

package-lock.json

Lines changed: 5 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@daostack/arc",
3-
"version": "0.0.1-rc.40",
3+
"version": "0.0.1-rc.41",
44
"description": "A platform for building DAOs",
55
"files": [
66
"contracts/",

test/competition.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,17 @@ contract('Competition', accounts => {
519519

520520
});
521521

522+
it("negative reputation change is not allowed", async function() {
523+
var testSetup = await setup(accounts);
524+
try {
525+
await proposeCompetition(testSetup,"description-hash",-1000);
526+
assert(false, 'negative reputation change is not allowed');
527+
} catch (ex) {
528+
helpers.assertVMException(ex);
529+
}
530+
await proposeCompetition(testSetup,"description-hash",0);
531+
});
532+
522533
it("redeem multipe suggestions", async function() {
523534
var testSetup = await setup(accounts);
524535
await testSetup.standardTokenMock.transfer(testSetup.org.avatar.address,3000,{from:accounts[1]});

test/contributionrewardext.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,4 +667,33 @@ contract('ContributionRewardExt', accounts => {
667667

668668
});
669669

670+
it("negativ rep change is not allowed for rewarder to set ", async function() {
671+
var testSetup = await setup(accounts,false,0,accounts[0]);
672+
var reputationReward = -12;
673+
var nativeTokenReward = 12;
674+
var ethReward = 12;
675+
var externalTokenReward = 12;
676+
try {
677+
await testSetup.contributionRewardExt.proposeContributionReward(
678+
web3.utils.asciiToHex("description"),
679+
reputationReward,
680+
[nativeTokenReward,ethReward,externalTokenReward],
681+
testSetup.standardTokenMock.address,
682+
testSetup.contributionRewardExt.address,
683+
helpers.NULL_ADDRESS
684+
);
685+
assert(false, 'negativ rep change is not allowed for rewarder to set');
686+
} catch (ex) {
687+
helpers.assertVMException(ex);
688+
}
689+
await testSetup.contributionRewardExt.proposeContributionReward(
690+
web3.utils.asciiToHex("description"),
691+
0,
692+
[nativeTokenReward,ethReward,externalTokenReward],
693+
testSetup.standardTokenMock.address,
694+
testSetup.contributionRewardExt.address,
695+
helpers.NULL_ADDRESS
696+
);
697+
});
698+
670699
});

0 commit comments

Comments
 (0)