Lesson 7: stagging test error AssertionError: expected '30000000000000000' to equal '0'
#1805
Answered
by
alymurtazamemon
ameeetgaikwad
asked this question in
Q&A
-
I'm having this error
Here is my code const { deployments, ethers, getNamedAccounts, network } = require("hardhat");
const { developmentChains } = require("../../helper-hardhat-config");
const { assert, expect } = require("chai");
developmentChains.includes(network.name)
? describe.skip
: describe("FundMe", function () {
let fundMe;
let deployer;
const sendValue = ethers.utils.parseEther("0.01");
beforeEach(async function () {
deployer = (await getNamedAccounts()).deployer;
fundMe = await ethers.getContract("FundMe", deployer);
});
it("allows people to fund and withdraw", async function () {
await fundMe.fund({ value: sendValue });
await fundMe.withdraw();
const endingBalance = await fundMe.provider.getBalance(fundMe.address);
assert.equal(endingBalance.toString(), "0");
});
}); |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Aug 15, 2022
Replies: 3 comments 39 replies
-
Diagnose why |
Beta Was this translation helpful? Give feedback.
5 replies
-
Please provide Fundme.sol . |
Beta Was this translation helpful? Give feedback.
4 replies
-
@ameeetgaikwad add a wait after withdraw, because it is changing the state of the blockchain. const tx = await fundMe.withdraw();
await tx.wait(1); |
Beta Was this translation helpful? Give feedback.
30 replies
Answer selected by
ameeetgaikwad
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ameeetgaikwad add a wait after withdraw, because it is changing the state of the blockchain.