The isEligibleForReward
function in the ScoreBoard.sol
contract incorrectly checks the number of predictions made by a player to determine their eligibility for a reward. Currently, a player needs to have made more than one prediction to be eligible, which excludes players who have made only one prediction.
The function isEligibleForReward
checks if the number of predictions made by a player is greater than one to determine eligibility for a reward. However, if the intent is to reward players who have made at least one prediction, this check should be adjusted to reflect that.
This is the test code of reward check.
To test this code:
Input this code to new test solidity file: test/CheckWithdraw.test.sol
.
Then run this command:
forge test --match-path test/CheckWithdraw.test.sol --match-test testWithdraw -vvvv
The result is:
As you can see, users who made only one prediction can't get their rewards.
Players who have made only one prediction are incorrectly excluded from receiving rewards, potentially leading to unfairness if rewards are intended for any player who participates.
The current implementation may result in players who meet all other conditions but made only one prediction being unfairly excluded from rewards.
Manual code review
Modify the isEligibleForReward
function to check if the number of predictions made by the player is greater than zero rather than one. This adjustment ensures that players who have made at least one prediction are considered for rewards.
Players with only one prediction cannot withdraw.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.