AssertionError: Expected transaction to be reverted with reason 'FundMe__NotOwner', but it reverted with a custom error
ZiJun0819 opened this issue · comments
ZiJun commented
await expect(fundMeConnectedContract.withdraw()).to.be.revertedWith(
"FundMe__NotOwner"
)
I think maybe due to the new version of "chai", so above code should be changed to this one
await expect(
fundMeConnectedContract.withdraw()
).to.be.revertedWithCustomError(
fundMeConnectedContract,
"FundMe__NotOwner"
)
})
Patrick Collins commented
Thanks! Would love to see a PR with the updated dependencies and tests!
w0nd3r commented
Awesome find, this solved my issue as well
rezvan niazi commented
well, the first argument of revertedWithCustomError
must be the contract that defines the custom error so instead of this:
fundMeConnectedContract.withdraw()
).to.be.revertedWithCustomError(
fundMeConnectedContract,
"FundMe__NotOwner"
)
})
we can do this as well:
await expect(
fundMeConnectedContract.withdraw()
).to.be.revertedWithCustomError(
fundMe,
"FundMe__NotOwner"
)
})