Users can call the enter_raffle function multiple times and take advantage in the raffle.
The function enter_raffle allows the users to participate in raffle. The function checks the amount of msg.value and the status of the raffle. If the msg.value is equal to ENTRANCE_FEE and the raffle is open, the function adds the caller to the players array.
But the function doesn't check if the caller is not already participant in the raffle. The caller can multiple times enter the raffle and increases the chance to win the raffle.
The test test_enter_raffle_multiple_times shows that the USER can enter raffle multiple times (in this test case - twice).
You can add the test to the snek_raffle_test.py and execute it using the command pytest -k 'test_enter_raffle_multiple_times' -s .
In that way the USER increases the chance to win the raffle
VS Code, pytest
Add a check to the enter_raffle function to ensure that the caller is not already participant in the raffle:
Add also the error: ERROR_ALREADY_PARTICIPANT: constant(String[46]) = "SnekRaffle: You are already a participant"
The above suggestion uses iteration over players array. Maybe more gas efficient way is to create a mapping that stores if a given address is a participant addresses: public(HashMap[address, bool]) and to check directly in the mapping:
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.