Open alexchenyu opened 1 year ago
In FundMe.test.js, the code below will report the error: Code:
it("Only allows the owner to withdraw", async function () { const accounts = await ethers.getSigners() const fundMeConnectedContract = await fundMe.connect( accounts[1] ) await expect( fundMeConnectedContract.withdraw() ).to.be.revertedWith("FundMe__NotOwner") })
Error: yarn hardhat test
AssertionError: Expected transaction to be reverted with reason 'FundMe__NotOwner', but it reverted with a custom error
New code:
it("Only allows the owner to withdraw", async function() { const accounts = await ethers.getSigners() const attacker = accounts[1] const attackerConnectedContract = await fundMe.connect(attacker) await expect( attackerConnectedContract.withdraw() ).to.be.revertedWithCustomError( attackerConnectedContract, "FundMe__NotOwner" ) })
@PatrickAlphaC maybe you can update your source code as well, thanks
Ah, we'd need to update all the packages too. Thanks for this issue!
Any chance you want to make it?
Yes, would like to have a try
This works, thanks!
In FundMe.test.js, the code below will report the error: Code:
Error: yarn hardhat test
New code:
@PatrickAlphaC maybe you can update your source code as well, thanks