Lesson 9 Unit test: Raffle__NotEnoughEthProvided #4663
-
Hello, I've a problem with the unit tests, all the tests that require an entrance fee gets reverted, I've written them out in the helper-config.js file, but for some reason, it does not seem to accept it... Does anyone have any idea why this could be happening? Example of error
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello @Holger-ap Your code seems to be ok. The only thing, which is interesting for me is that how are you running your tests as command |
Beta Was this translation helpful? Give feedback.
-
@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 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 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 (msg.value < i_enteranceFee) {
revert Raffle__NotEnoughEthProvided();
} |
Beta Was this translation helpful? Give feedback.
@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;But you have the condition inside the
enterRaffle
function this;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;