Closed Puchacz1 closed 2 years ago
it("fails if payment isn't sent with the request", async function () {
await expect(randomIpfsNft.requestNft()).to.be.revertedWith(
"RandomIpfsNft__NeedMoreETHSent"
);
});
it("reverts if payment amount is less than the mint fee", async function () {
const fee = await randomIpfsNft.getMintFee();
await expect(
randomIpfsNft.requestNft({
value: mintFee.sub(ethers.utils.parseEther("0.01")),
})
).to.be.revertedWith("RandomIpfsNft__NeedMoreETHSent");
});
You need to change RandomIpfsNft__NeedMoreETHSent
to NeedMoreETHSent
in both of these it block because you have defined your custom error as NeedMoreETHSent
in your contract.
And, in the second it block, you have declared fee
variable to store mint fee, but uses mintFee
when calling requestNft function. Change mintFee
to fee
.
thank u so much
No problem, have fun learning. And you need to spend some time looking at the error. Your problem is clearly stated in the error and if you have read the error thoroughly and understand it, yo'd have fix the error yourself in no time.
When testing RandomIpfsNft i m getting this 1) fails if payment isn't sent with the request 2) reverts if payment amount is less than the mint fee
AssertionError: Expected transaction to be reverted with RandomIpfsNft__NeedMoreETHSent, but other exception was thrown: Error: VM Exception while processing transaction: reverted with custom error 'NeedMoreETHSent()'
ReferenceError: mintFee is not defined my code:
RandomIpfsNft.sol
02-deploy-random-ipfs.js
helper-hardhat-config.js
test/randomIpfs.test.js :
I was trying to set diffrent mintfees and nothing helped:(
btw have a nice day