Skip to content

Lesson 9 Unit test: Raffle__NotEnoughEthProvided #4663

Answered by alymurtazamemon
Holger-ap asked this question in Q&A
Discussion options

You must be logged in to vote

@Holger-ap Hey! You are facing this issue because you are getting this entrance fee from the contract and sending it as a value to enterRaffle function here;

it("records players when they enter the game", async function () {
    await raffle.enterRaffle({ value: raffleEntranceFee })
    const playerFromContract = await raffle.getPlayer(0)
    assert.equal(playerFromContract, deployer)
})

But you have the condition inside the enterRaffle function this;

if (msg.value <= i_enteranceFee) {
    revert Raffle__NotEnoughEthProvided();
}

So obviously the value will be equal to the entrance fee because you are sending an equal amount which is why it is throwing the error. It should be like this;

if (

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Holger-ap
Comment options

Answer selected by Holger-ap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants