The error when the user send more than the ENTRANCE_FEE
when calling the enter_raffle
function is confusing.
The enter_raffle
function requires a caller to send a given amount of fee in order to participate in the raffle.
There is a check if the msg.value
is equal to the ENTRANCE_FEE
. If the send amount is different from the ENTRANCE_FEE
, the function reverts with error: ERROR_SEND_MORE_TO_ENTER_RAFFLE
.
But the function will also revert if the msg.value
is greater than the ``ENTRANCE_FEE`.
The following test case shows that the USER
sends more than the ENTRANCE_FEE
when calls enter_raffle
function and the function reverts. The USER
receives the error: ERROR_SEND_MORE_TO_ENTER_RAFFLE
. But this error message in that case is inappropriate. If the USER
calls again the function with more msg.value
, the result will be the same. This leads to confusion for the USER
.
You can add the test to the snek_raffle_test.py
and execute it using the command pytest -k 'test_raffle_reverts_when_you_pay_more'
.
VS Code, pytest
Change the error message with something more appropriate for the both cases: when the user send less or more than the ENTRANCE_FEE
.
For example:
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.