MartenitsaVoting::announceWinner
fails to properly address scenarios where multiple NFTs receive the same highest number of votes.
MartenitsaVoting::announceWinner
is supposed to
identify the NFT(s) with the highest number of votes at the end of the voting period,
announce it/them as the winner(s), and
reward the the owner(s) of the NFT(s) with 1 healthToken
.
However, the current implementation does not handle cases where two or more NFTs receive the highest but equal number of votes.
The test below simulates a voting scenario where:
Two NFTs (token ID 0
and token ID 1
) are listed and receive an equal number of votes (1 each).
The voting concludes, and the winner is announced.
Despite the tie, only the owner of token ID 0
receives the reward.
In cases when mulitple NFTs have the highest but equal number of votes (i.e. tied winners), the contract arbitrarily rewards the NFT that appears first in the iteration that still has the maximum votes, while the other "winners" will not get any rewards.
Manual review, Foundry.
Adjust the code in MartenitsaVoting
as follows:
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.