Skip to content

Commit

Permalink
bug fix : zero beneficiary daobounty only if actual redeeming was don…
Browse files Browse the repository at this point in the history
…e. (#522)

* zero daobounty only if actual redeeming was done.

* enhanced daobounty test

* bump version to 0.0.0-alpah.50
  • Loading branch information
orenyodfat authored Aug 15, 2018
1 parent eb9b93d commit ae6f0af
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/VotingMachines/GenesisProtocol.sol
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,11 @@ contract GenesisProtocol is IntVoteInterface,UniversalScheme {
if (potentialAmount > beneficiaryLimit) {
potentialAmount = beneficiaryLimit;
}
proposal.stakers[_beneficiary].amountForBounty = 0;
}
if ((potentialAmount != 0)&&(stakingToken.balanceOf(proposal.avatar) >= potentialAmount)) {
proposal.daoBountyRemain = proposal.daoBountyRemain.sub(potentialAmount);
require(ControllerInterface(Avatar(proposal.avatar).owner()).externalTokenTransfer(stakingToken,_beneficiary,potentialAmount,proposal.avatar));
proposal.stakers[_beneficiary].amountForBounty = 0;
redeemedAmount = potentialAmount;
emit RedeemDaoBounty(_proposalId,proposal.avatar,_beneficiary,redeemedAmount);
}
Expand Down
2 changes: 1 addition & 1 deletion 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.0-alpha.49",
"version": "0.0.0-alpha.50",
"description": "A platform for building DAOs",
"files": [
"contracts/",
Expand Down
5 changes: 5 additions & 0 deletions test/genesisprotocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,8 @@ contract('GenesisProtocol', function (accounts) {
//'there is no tokens on the dao for bounty'
assert.equal(stakerRedeemAmountBaunty,0);
//send tokens to org avatar
tx = await testSetup.genesisProtocol.redeemDaoBounty(proposalId,accounts[0]);
assert.equal(tx.logs.length,0); //not enough funds
await testSetup.stakingToken.transfer(testSetup.org.avatar.address,potentialAmount);
tx = await testSetup.genesisProtocol.redeemDaoBounty(proposalId,accounts[0]);
assert.equal(tx.logs.length,1);
Expand All @@ -1554,6 +1556,9 @@ contract('GenesisProtocol', function (accounts) {
assert.equal(tx.logs[0].args._amount, potentialAmount.toNumber());
assert.equal(await testSetup.stakingToken.balanceOf(accounts[0]),900);

tx = await testSetup.genesisProtocol.redeemDaoBounty(proposalId,accounts[0]);
assert.equal(tx.logs.length,0);

});

it("redeem dao bounty for unsuccessful proposal", async () => {
Expand Down

0 comments on commit ae6f0af

Please sign in to comment.