error running "FundMe.test" #4378
Replies: 2 comments 2 replies
-
@Muktarsadiq What you did can let us know? Or why don't you try to watch the Testing parts of Fund Me lesson? |
Beta Was this translation helpful? Give feedback.
-
As I see you might have a problem creating your contract and deploying it. Also you have some big number conversion problems as well. Do not forget! Whenever we get some number from chain it is big number. Do not forget to toString()! Do not forget deploying the contract in beforeEach part in the beginning. let fundMe;
let deployer;
let mockV3Aggregator;
//const sendValue= "10000000000000000" // 1 ETH
const sendValue = ethers.utils.parseEther("1")
beforeEach(async () => {
deployer = (await getNamedAccounts()).deployer
await deployments.fixture(["all"])
fundMe = await ethers.getContract("FundMe", deployer)
mockV3Aggregator = await ethers.getContract("MockV3Aggregator", deployer)
}) It is better if you just comment out all other tests instead of the first one which fails and send your code here and the first error we can check |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
At 11:40:00
I waited to run all my tests for my fundMe.test and I received errors for each and every one of them, here's the full error below
user@users-MBP hardhat-fundme % yarn hardhat test
yarn run v1.22.19
warning package.json: No license field
$ /Users/user/Desktop/hardhat-fundme/node_modules/.bin/hardhat test
FundMe
constructor
0 passing (1s)
7 failing
FundMe
constructor
sets the aggregator addresses correctly:
TypeError: fundMe.getPriceFeed is not a function
at Context. (test/staging/units/FundMe.test.js:24:43)
at processImmediate (node:internal/timers:466:21)
FundMe
fund
Fails if you don't send enough ETH:
AssertionError: Expected transaction to be reverted with reason 'You need to spend more ETH!', but it didn't revert
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
at Context. (test/staging/units/FundMe.test.js:33:13)
FundMe
fund
Updates the amount funded data structure:
TypeError: fundMe.getAddressToAmountFunded is not a function
at Context. (test/staging/units/FundMe.test.js:41:43)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
FundMe
fund
Adds funder to array of funders:
TypeError: fundMe.getFunder is not a function
at Context. (test/staging/units/FundMe.test.js:48:43)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
FundMe
withdraw
withdraws ETH from a single funder:
AssertionError: expected { Object (_hex, _isBigNumber) } to equal +0
at Context. (test/staging/units/FundMe.test.js:77:20)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
FundMe
withdraw
is allows us to withdraw with multiple funders:
TypeError: fundMe.cheaperWithdraw is not a function
at Context. (test/staging/units/FundMe.test.js:102:54)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
FundMe
withdraw
Only allows the owner to withdraw:
AssertionError: Expected transaction to be reverted with reason 'NotOwner', but it didn't revert
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
at Context. (test/staging/units/FundMe.test.js:140:13)
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
user@users-MBP hardhat-fundme %
please I currently need help with this, Thank you
Beta Was this translation helpful? Give feedback.
All reactions