Hello im getting the following Error when i run my test on the withdraw functio:
`FundMe
constructor
✓ sets the aggregator address correctly
fund
✓ fails if u dont send enough eth
✓ updated the amount funded data structure
✓ adds funders to array of funders
withdraw
1) withdraw ETH from a single founder
4 passing (2s)
1 failing
1) FundMe
withdraw
withdraw ETH from a single founder:
Error: invalid BigNumber value (argument="value", value={}, code=INVALID_ARGUMENT, version=bignumber/5.7.0)
at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
at Logger.throwArgumentError (node_modules/@ethersproject/logger/src.ts/index.ts:285:21)
at Function.BigNumber.from (node_modules/@ethersproject/bignumber/src.ts/bignumber.ts:289:23)
at toBN (node_modules/@ethersproject/bignumber/src.ts/bignumber.ts:345:27)
at BigNumber.add (node_modules/@ethersproject/bignumber/src.ts/bignumber.ts:74:43)
at Context. (test/unit/FundMe.test.js:75:39)
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)`
let fundMe
let deployer
let mockV3Aggregator
const sendValue = ethers.utils.parseEther("5")
beforeEach(async function() {
deployer = (await getNamedAccounts()).deployer
await deployments.fixture(["all"])
fundMe = await ethers.getContract("FundMe", deployer)
mockV3Aggregator = await ethers.getContract(
"MockV3Aggregator",
deployer
)
})
describe("constructor", async function() {
it("sets the aggregator address correctly", async function() {
const response = await fundMe.priceFeed()
assert.equal(response, mockV3Aggregator.address)
})
})
describe("fund", async function() {
it("fails if u dont send enough eth", async function() {
await expect(fundMe.fund()).to.be.revertedWith(
"failure, did not have enough"
)
})
it("updated the amount funded data structure", async function() {
await fundMe.fund({ value: sendValue })
const response = await fundMe.addressToAmountFunded(deployer)
assert.equal(response.toString(), sendValue.toString())
})
it("adds funders to array of funders", async function() {
await fundMe.fund({ value: sendValue })
const funder = await fundMe.funders(0)
assert.equal(funder, deployer)
})
})
describe("withdraw", async function() {
beforeEach(async function() {
await fundMe.fund({ value: sendValue })
})
it("withdraw ETH from a single founder", async function() {
//arrange
const startingFundMeBalance = await fundMe.provider.getBalance(
fundMe.address
)
const startingDeployerBalance = fundMe.provider.getBalance(deployer)
//act
const transactionResponse = await fundMe.withdraw()
const transactionReceipt = await transactionResponse.wait(1)
//breakpoint the code will stop here
const { gasUsed, effectiveGasPrice } = transactionReceipt // we pull out these to, from another object, the debugger?
const gasCost = gasUsed.mul(effectiveGasPrice) //multiply them together *
const endingFundMeBalance = await fundMe.provider.getBalance(
fundMe.address
)
const endingDeployerBalance = await fundMe.provider.getBalance(
deployer
)
//assert
assert.equal(endingFundMeBalance, 0) //should be 0 because we just withdrew all the eth.
assert.equal(
startingFundMeBalance.add(startingDeployerBalance).toString(),
endingDeployerBalance.add(gasCost).toString() // the starting FundMe balance + the deployer balance which should be equal to the amount he deployed in the first place, we use .add because it reads from the blockchain and it's a bigNumber. we also add gas cost to the ending, because otherwise it wont be equal, because he paid a bit of gas when he called the function ofc.
)
})
})
Hello im getting the following Error when i run my test on the withdraw functio:
`FundMe constructor ✓ sets the aggregator address correctly fund ✓ fails if u dont send enough eth ✓ updated the amount funded data structure ✓ adds funders to array of funders withdraw
4 passing (2s) 1 failing
1) FundMe withdraw withdraw ETH from a single founder: Error: invalid BigNumber value (argument="value", value={}, code=INVALID_ARGUMENT, version=bignumber/5.7.0) at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:269:28) at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:281:20) at Logger.throwArgumentError (node_modules/@ethersproject/logger/src.ts/index.ts:285:21) at Function.BigNumber.from (node_modules/@ethersproject/bignumber/src.ts/bignumber.ts:289:23) at toBN (node_modules/@ethersproject/bignumber/src.ts/bignumber.ts:345:27) at BigNumber.add (node_modules/@ethersproject/bignumber/src.ts/bignumber.ts:74:43) at Context. (test/unit/FundMe.test.js:75:39)
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)`
This is my code:
`const { assert, expect } = require("chai") const { deployments, ethers, getNamedAccounts } = require("hardhat") const { isCallTrace } = require("hardhat/internal/hardhat-network/stack-traces/message-trace")
describe("FundMe", async function() {
})`