Note: The documentation does not clarify whether the game owner is allowed to end the game before the scheduled end time. In the scenario presented below, the owner of the game contract can end the game before the specified time limit.
When the game owner ends the game before the initial time limit, calling the EggHuntGame::getTimeRemaining function still returns the remaining time based on the initial duration. This is incorrect, as the game is no longer active. The function should reflect that the game has ended and return zero instead.
When the owner starts the game, he sets its duration but can also choose to end it early. Any user can call the EggHuntGame::getTimeRemaining function to check how much time is left. However, if the owner ends the game early, this function still returns the time remaining based on the original duration, which is incorrect.
The possibility that the EggHuntGame::getTimeRemaining function may return an invalid value.
Add the following code to the EggHuntGameTest.t.sol file within the EggGameTest contract.
Manual Review
Foundry
To ensure the function always returns the correct value, it should also check whether the game is still active. Recommended changes in the EggHuntGame contract.
Incorrect values reported when a game is ended early
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.