Skip to content

Commit

Permalink
fix scoring unfinished rounds (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber authored Oct 4, 2023
1 parent 8c67f49 commit aaf1724
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ImpactEvaluator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,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 @@ -166,6 +166,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

0 comments on commit aaf1724

Please sign in to comment.