diff --git a/src/ImpactEvaluator.sol b/src/ImpactEvaluator.sol index c5daad7..7ae0867 100644 --- a/src/ImpactEvaluator.sol +++ b/src/ImpactEvaluator.sol @@ -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"); diff --git a/test/ImpactEvaluator.t.sol b/test/ImpactEvaluator.t.sol index 28baef9..8bc22b5 100644 --- a/test/ImpactEvaluator.t.sol +++ b/test/ImpactEvaluator.t.sol @@ -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);