I'm writing a test that requires enterRaffle() to be reverted with MyCustomError - "Raffle__NotEnoughEthEntered"
describe("enterRaffle", async function () {
it("reverts when you don't pay enough", async function () {
await expect(raffle.enterRaffle()).to.be.revertedWith(
"Raffle__NotEnoughEthEntered"
)
})
})
The test fails with error;
1) Raffle
enterRaffle
reverts when you don't pay enough:
AssertionError: Expected transaction to be reverted with reason 'Raffle__NotEnoughEthEntered', but it reverted with a custom error
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Context.<anonymous> (test/unit/Raffle.test.js:32:19)
Why is Raffle__NotEnoughEthEntered not a custom error?
I have read other similar issues but they don't solve my problem.
Raffle.sol error
& enterRaffle
error Raffle__NotEnoughEthEntered();
////////////////////////////////////////////////////////////////////////////////////////////////////
function enterRaffle() public payable {
// you can do this,
//require (msg.value > i_enteranceFee, "Not Enough ETH!")
// but we will use error codes for gas efficiency since storing strings if supper expensive
if (msg.value < i_enteranceFee) {
revert Raffle__NotEnoughEthEntered();
}
if (s_raffleState != RaffleState.OPEN) {
revert Raffle__NotOpen();
}
s_players.push(payable(msg.sender));
//Emit an event when we update a dynamic array or mapping
//name events with fuction name reversed. in this case event RaffleEnter()
emit RaffleEnter(msg.sender);
}