Skip to content

Commit

Permalink
return 0 for getDelegateRewards if didn't vote in the screening stage
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike committed Sep 15, 2023
1 parent c657492 commit 232e817
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ build :; forge clean && forge build --optimize --optimizer-runs 1000000
# Tests
tests :; forge clean && forge test --mt test --optimize --optimizer-runs 1000000 -v # --ffi # enable if you need the `ffi` cheat code on HEVM
test-with-gas-report :; forge clean && forge build && forge test --mt test --optimize --optimizer-runs 1000000 -v --gas-report # --ffi # enable if you need the `ffi` cheat code on HEVM
test-unit :; forge clean && forge test --no-match-test invariant --optimize --optimizer-runs 1000000 -v # --ffi # enable if you need the `ffi` cheat code on HEVM
test-invariant :; ./test/invariants/test-invariant.sh ${SCENARIO} ${NUM_ACTORS} ${NUM_PROPOSALS} ${PER_ADDRESS_TOKEN_REQ_CAP}
test-invariant-all :; forge clean && forge t --mt invariant
test-invariant-multiple-distribution :; forge clean && ./test/invariants/test-invariant.sh MultipleDistribution 2 25 200
Expand Down
2 changes: 2 additions & 0 deletions src/grants/GrantFund.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,8 @@ contract GrantFund is IGrantFund, Storage, ReentrancyGuard {
DistributionPeriod storage currentDistribution = _distributions[distributionId_];
VoterInfo storage voter = _voterInfo[distributionId_][voter_];

if (voter.screeningVotesCast == 0) return 0;

rewards_ = _getDelegateReward(currentDistribution, voter);
}

Expand Down
4 changes: 4 additions & 0 deletions test/unit/StandardFunding.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,10 @@ contract StandardFundingGrantFundTest is GrantFundTestHelper {
/******************************/

// Claim delegate reward for all delegatees
// delegates who didn't vote in the screening stage have zero rewards
delegateRewards = _grantFund.getDelegateReward(distributionId, _tokenHolder11);
assertEq(delegateRewards, 0);

// delegates who didn't vote with their full power receive fewer rewards
delegateRewards = _grantFund.getDelegateReward(distributionId, _tokenHolder1);
assertEq(delegateRewards, 327_029.344384908148174595 * 1e18);
Expand Down

0 comments on commit 232e817

Please sign in to comment.