diff --git a/src/DerolasAuction.sol b/src/DerolasAuction.sol index 301a303..fd588b9 100644 --- a/src/DerolasAuction.sol +++ b/src/DerolasAuction.sol @@ -311,6 +311,7 @@ contract DerolasAuction { ); require(roundToDonations[curRound][msg.sender] == 0, "Already donated this round"); + require(getRemainingRoundLength() > 0, "Round has ended"); roundPoints[curRound].totalDonated += msg.value; roundToDonations[curRound][msg.sender] = msg.value; diff --git a/test/DerolasAuction.t.sol b/test/DerolasAuction.t.sol index b012338..9dba3d3 100644 --- a/test/DerolasAuction.t.sol +++ b/test/DerolasAuction.t.sol @@ -408,4 +408,13 @@ contract TestDerolasAuctionContract is Test { assertLt(address(c).balance, minimumTradeAmount, "Contract should have less than minimum trade amount in ETH"); this.testCanEndRound(); // Ensure the round can be ended without failing } + + function testCannotDonateAfterRoundEnd() public { + // Check that a user cannot donate after the round has ended + this.testTopupIncentivesBalance(); // Ensure incentives are topped up + // fast-forward to the block after the round length + vm.roll(block.number + roundLength + 1); + vm.expectRevert("Round has ended"); + c.donate{value: minimumDonation}(); // Attempt to donate after round end + } }