The s_previousVoteEndTimeStamp
is never initialized in the constructor, causing the selectPresident()
function to always revert.
Without initializing s_previousVoteEndTimeStamp
, it defaults to 0. As a result, the condition in selectPresident()
that checks if enough time has passed since the last vote: https://github.com/Cyfrin/2024-09-president-elector/blob/fccb8e2b6a32404b4664fa001faa334f258b4947/src/RankedChoice.sol#L61 will always evaluate to true on the first call, leading to the function reverting with the RankedChoice__NotTimeToVote
error, since the previousVoteEndTimeStamp
isn't initialized thus empty.
This bug prevents the president selection process from being completed successfully, as the contract will always revert on the first attempt to select a president. As a result, no new president can be chosen, disrupting the election process.
Add this at your test suits:
Foundry
Initialize s_previousVoteEndTimeStamp
in the constructor, with the previous timestamp that was set after the selection of a president.
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.