AssertionError: Expected transaction to be reverted with reason 'Raffle__NotEnoughEthEntered', but it reverted with a custom error #2702
-
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
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 13 replies
-
@kihiuFrank try this |
Beta Was this translation helpful? Give feedback.
-
Hey @kihiuFrank try and use
|
Beta Was this translation helpful? Give feedback.
-
I am having the same issue but while using the transparent proxy pattern from open zepplin. say i have raffleProxy, and raffleImpl contracts. When calling the expect like this
When calling the expect with raffleImpl, it works as expected as the errors are defined in the implementation Is there anyway to make this work with the proxy ? |
Beta Was this translation helpful? Give feedback.
Hey @kihiuFrank try and use
to.be.revertedWithCustomError()
instead and see if it works.The line should read something like this