TypeError: gasPrice.mul is not a function in FundMe Test #6407
-
I am not able to get why it is showing mul() is not a function as it is there in ethers. const { assert, expect } = require("chai");
const { network, deployments, ethers, getNamedAccounts } = require("hardhat");
const { developmentChains } = require("../../helper-hardhat-config");
describe("FundMe", function () {
let fundMe, deployer, mockV3Aggregator;
const sendValue = ethers.parseEther("1");
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("It sets the Aggregator address correctly", async function () {
const response = await fundMe.priceFeed();
assert.equal(response, await mockV3Aggregator.getAddress());
});
});
// describe("recieve", async function () {});
describe("fund", async function () {
it("Fails if you don't send enough ETH!", async function () {
await expect(fundMe.fund()).to.be.revertedWith(
"Don't have enough Balance"
);
});
it("Updates the funder's address in funders array", async function () {
await fundMe.fund({ value: sendValue });
assert.equal(deployer, await fundMe.funders(0));
});
it("Updates the funded amount in the mapping data structure", async function () {
await fundMe.fund({ value: sendValue });
const response = await fundMe.addressToAmount(deployer);
assert.equal(response.toString(), sendValue.toString());
});
});
describe("withdraw", async function () {
beforeEach(async function () {
await fundMe.fund({ value: sendValue });
});
it("Withdraw funds from single founder", async function () {
// Arrange
const startingContractBalance = await ethers.provider.getBalance(
await fundMe.getAddress()
);
const startingDeployerBalance = await ethers.provider.getBalance(
deployer
);
// Act
const transactionResponce = await fundMe.withdraw();
const transactionReciept = await transactionResponce.wait(1);
const { gasPrice, gasUsed } = transactionReciept;
const gasCost = gasPrice.mul(gasUsed);
const endingContractBalance = await ethers.provider.getBalance(
await fundMe.getAddress()
);
const endingDeployerBalance = await ethers.provider.getBalance(
deployer
);
// Assert
assert.equal(endingContractBalance, 0);
assert.equal(
endingDeployerBalance.add(gasCost).toString(),
startingDeployerBalance.add(startingContractBalance).toString()
);
});
});
}); Here is the error
|
Beta Was this translation helpful? Give feedback.
Answered by
Codensity30
Jan 19, 2024
Replies: 1 comment
-
In the upgraded version of, |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nraj07054
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the upgraded version of,
ethers
thesemul, add, ...
functions are not supported. These functions are used to perform basic arithmetic operations.So you can use this instead
const gasCost = gasPrice * gasUsed;
this will also lead to same result.