Open elliottmcknight opened 1 year ago
@elliottmcknight What version of chai are you using? Did you install the @nomicfoundation/hardhat-toolbox
package as suggested in the hardhat documentation?
Hi I am also stuck on this section but getting a different error message as follows:
FundMe
constructor
✔ sets the aggregator addresses correctly
fund
1) Fails if you don't send enough ETH
1 passing (727ms)
1 failing
1) FundMe
fund
Fails if you don't send enough ETH:
AssertionError: Expected transaction to be reverted with reason 'more ETH is needed!', but it reverted with reason 'Please send more ETH!'
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:533:9)
at processTimers (node:internal/timers:507:7)
at Context.<anonymous> (test/unit/FundMe.test.js:30:13)
any idea to solve this?
Hi I am also stuck on this section but getting a different error message as follows:
FundMe constructor ✔ sets the aggregator addresses correctly fund 1) Fails if you don't send enough ETH 1 passing (727ms) 1 failing 1) FundMe fund Fails if you don't send enough ETH: AssertionError: Expected transaction to be reverted with reason 'more ETH is needed!', but it reverted with reason 'Please send more ETH!' at processTicksAndRejections (node:internal/process/task_queues:95:5) at runNextTicks (node:internal/process/task_queues:64:3) at listOnTimeout (node:internal/timers:533:9) at processTimers (node:internal/timers:507:7) at Context.<anonymous> (test/unit/FundMe.test.js:30:13)
any idea to solve this?
I solved this by omitting 'await', so it is written as follows:
describe("fund", async function() {
it("Fails if you don't send enough ETH", async function() {
expect(fundMe.fund()).to.be.revertedWith(
"You need to spend more ETH!"
I have no idea why it solves the problem? but I got the idea of deleting 'await' from the the other issues thread.
i am getting: 0 passing (3s) 1 failing
1) FundMe "before each" hook for "sets the aggregator addresses correctly": TypeError: Cannot read properties of undefined
To resolve the issue, you can follow these steps:
require("@nomiclabs/hardhat-waffle")
.require("@nomicfoundation/hardhat-chai-matchers")
.Good Morning!!. I think I found a way to solve this issue...
I also got this error:
van123@Van-PC:~/blockchain-tuts/hardhat-fundme$ yarn hardhat test
yarn run v1.22.15
$ /home/van123/blockchain-tuts/hardhat-fundme/node_modules/.bin/hardhat test
FundMe
constructor
✔ sets the aggregator address correctly
fund
1) fails if we dont send enough eth
1 passing (3s)
1 failing
1) FundMe
fund
fails if we dont send enough eth:
AssertionError: Expected transaction to be reverted with Not enough eth!, but other exception was thrown: Error: VM Exception while processing transaction: reverted with reason string 'Not enough eth'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I have been searching for ways to solve this and found that removing "await" does solve it but it is really not right since it returns promise.
describe('fund', () => {
it('fails if we dont send enough eth', async () => {
expect(fundMe.fund()).to.be.revertedWith('Not enough eth!');
});
});
the right thing is still to add await, but it has to match the reverted message from the solidity!!, you should check your FundMe.sol file if it matches the reverted message
FundMe.test.js:
describe('fund', () => {
it('fails if we dont send enough eth', async () => {
await expect(fundMe.fund()).to.be.revertedWith('Not enough eth');
});
});
FundMe.sol
function fund() public payable {
require(
msg.value.getConversionRate(priceFeed) >= MINIMUM_USD,
'Not enough eth'
);
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender);
}
hope this helps
@VINURIRODRIGO thanks it worked
I am receiving an error when running the "yarn hardhat test" command. Once I run the command, I get this message: