Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.7.0)
PS E:\Block Chain Projects\FUND_ME_FULLSTACK> yarn hardhat test
yarn run v1.22.15
warning ..\package.json: No license field
$ "E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\.bin\hardhat" test
Funde
constructor
✔ Sets the aggregator address correctly (50ms)
Fund
✔ Fails if u don't send enought ethers (147ms)
✔ Update the amount funded data structure (104ms)
✔ Funder Upated to fund array (108ms)
Withdraw
1) Withdraw Eth From a single Founder
4 passing (2s)
1 failing
1) Funde
Withdraw
Withdraw Eth From a single Founder:
Error: invalid BigNumber value (argument="value", value=undefined, 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.mul (node_modules\@ethersproject\bignumber\src.ts\bignumber.ts:90:43)
at Context.<anonymous> (test\units\FundMe.test.js:58:42)
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)
MY FundMe.test.js The Problem is in Withdraw Describe (ERROR of BIGNUMBER ) unable to find the bug
const {deployments, ethers,getNamedAccounts} = require("hardhat");
const {assert, expect} = require("chai");
describe("Funde",async function () {
let fundme;
let deployer;
let mockV3Aggregator;
let sendvalue = ethers.utils.parseEther("1"); //! Ether
beforeEach(async ()=>
{
// DEPLOY THE CONTRACT USING HARDHAT DEPLOY
deployer = (await getNamedAccounts()).deployer;
await deployments.fixture("all"); // -> with one line of code deploy all deploy.js files
// fixture uses tags given in the deploy folders using module.exports\
//console.log(deployer);
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.getPriceFeed();
////console.log(response);
//console.log(mockV3Aggregator.address);
assert.equal(response,mockV3Aggregator.address);
});
});
describe("Fund",async function()
{
it("Fails if u don't send enought ethers",async function ()
{
await expect(fundme.fund()).to.be.revertedWith("You need to spend more ETH!");
});
it("Update the amount funded data structure",async ()=>{
await fundme.fund({value:sendvalue})
const response = await fundme.getAddressToAmountFunded(deployer);
assert.equal(response.toString(),sendvalue.toString());
});
it("Funder Upated to fund array",async () =>{
await fundme.fund({value:sendvalue})
const response = await fundme.getFunder(0);
assert.equal(response,deployer);
});
});
describe("Withdraw",async function(){
beforeEach(async function(){
await fundme.fund({value:sendvalue});
})
it("Withdraw Eth From a single Founder",async function()
{
//Arrange
const initialbalance = await fundme.provider.getBalance(fundme.address);
const initialdeploybalance = await fundme.provider.getBalance(deployer);
//ACT
const withdrawfund = await fundme.withdraw();
const Transactionreciept = await withdrawfund.wait();
const {gasUsed,effecttiveGasPrice} = Transactionreciept;
const totalgasused = gasUsed.mul(effecttiveGasPrice);
console.log(totalgasused);
const Endingbalance = await fundme.provider.getBalance(fundme.address);
const Endingdeployerbalance = await fundme.provider.getBalance(deployer);
//ASSERT
assert.equal(Endingbalance,0);
assert.equal(initialbalance.add(initialdeploybalance)
.toString(),
Endingdeployerbalance.add(totalgasused)
.toString());
});
});
});
const totalgasused = gasUsed.mul(effecttiveGasPrice); I think the error is in this line WHY Am I unable to get the totalgasused..I tried JS-DEBUGGER TO but was unable to find the bug