Skip to content

competition reputation change should be >=0 #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/schemes/Competition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ contract Competition {
/**
* @dev Submit a competion proposal
* @param _descriptionHash A hash of the proposal's description
* @param _reputationChange - Amount of reputation change requested .Can be negative.
* @param _reputationChange - Amount of reputation change requested.
* @param _rewards rewards array:
* rewards[0] - Amount of tokens requested per period
* rewards[1] - Amount of ETH requested per period
Expand Down Expand Up @@ -146,7 +146,7 @@ contract Competition {
if (_rewards[2] > 0) {
require(_externalToken != ERC20(0), "extenal token cannot be zero");
}
require(_reputationChange > 0, "only positive rep change(minting) allowed for a competition");
require(_reputationChange >= 0, "negative reputation change is not allowed for a competition");
uint256 totalRewardSplit;
for (uint256 i = 0; i < numberOfWinners; i++) {
totalRewardSplit = totalRewardSplit.add(_rewardSplit[i]);
Expand Down
2 changes: 1 addition & 1 deletion contracts/schemes/ContributionRewardExt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ contract ContributionRewardExt is VotingMachineCallbacks, ProposalExecuteInterfa
beneficiary = msg.sender;
}
if (beneficiary == address(this)) {
require(_reputationChange > 0, "only positive rep change(minting) allowed for this case");
require(_reputationChange >= 0, "negative rep change not allowed for this case");
}

ContributionProposal memory proposal = ContributionProposal({
Expand Down
19 changes: 5 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@daostack/arc",
"version": "0.0.1-rc.40",
"version": "0.0.1-rc.41",
"description": "A platform for building DAOs",
"files": [
"contracts/",
Expand Down
11 changes: 11 additions & 0 deletions test/competition.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,17 @@ contract('Competition', accounts => {

});

it("negative reputation change is not allowed", async function() {
var testSetup = await setup(accounts);
try {
await proposeCompetition(testSetup,"description-hash",-1000);
assert(false, 'negative reputation change is not allowed');
} catch (ex) {
helpers.assertVMException(ex);
}
await proposeCompetition(testSetup,"description-hash",0);
});

it("redeem multipe suggestions", async function() {
var testSetup = await setup(accounts);
await testSetup.standardTokenMock.transfer(testSetup.org.avatar.address,3000,{from:accounts[1]});
Expand Down
29 changes: 29 additions & 0 deletions test/contributionrewardext.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,4 +667,33 @@ contract('ContributionRewardExt', accounts => {

});

it("negativ rep change is not allowed for rewarder to set ", async function() {
var testSetup = await setup(accounts,false,0,accounts[0]);
var reputationReward = -12;
var nativeTokenReward = 12;
var ethReward = 12;
var externalTokenReward = 12;
try {
await testSetup.contributionRewardExt.proposeContributionReward(
web3.utils.asciiToHex("description"),
reputationReward,
[nativeTokenReward,ethReward,externalTokenReward],
testSetup.standardTokenMock.address,
testSetup.contributionRewardExt.address,
helpers.NULL_ADDRESS
);
assert(false, 'negativ rep change is not allowed for rewarder to set');
} catch (ex) {
helpers.assertVMException(ex);
}
await testSetup.contributionRewardExt.proposeContributionReward(
web3.utils.asciiToHex("description"),
0,
[nativeTokenReward,ethReward,externalTokenReward],
testSetup.standardTokenMock.address,
testSetup.contributionRewardExt.address,
helpers.NULL_ADDRESS
);
});

});