Skip to content
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

fix scoring unfinished rounds #35

Merged
merged 1 commit into from
Oct 4, 2023
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
1 change: 1 addition & 0 deletions src/ImpactEvaluator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ contract ImpactEvaluator is AccessControl {
addresses.length == scores.length,
"Addresses and scores length mismatch"
);
require(roundIndex < currentRoundIndex(), "Round not finished");
Round storage round = rounds[roundIndex];
require(round.exists, "Round does not exist");
require(!round.scoresSubmitted, "Scores already submitted");
Expand Down
8 changes: 8 additions & 0 deletions test/ImpactEvaluator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ contract ImpactEvaluatorTest is Test {
impactEvaluator.setScores(0, addresses, scores, "0 tasks performed");
}

function test_SetScoresUnfinishedRound() public {
ImpactEvaluator impactEvaluator = new ImpactEvaluator(address(this));
address payable[] memory addresses = new address payable[](0);
uint64[] memory scores = new uint64[](0);
vm.expectRevert("Round not finished");
impactEvaluator.setScores(0, addresses, scores, "0 tasks performed");
}

function test_CurrentRoundMeasurementCount() public {
ImpactEvaluator impactEvaluator = new ImpactEvaluator(address(this));
assertEq(impactEvaluator.currentRoundMeasurementCount(), 0);
Expand Down