Project Ready
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
//Last Step Before Going to Mainnet
|
||||
|
||||
const { ethers, deployments, getNamedAccounts } = require("hardhat");
|
||||
const { expect, assert } = require("chai");
|
||||
const { developmentChains } = require("../../helper-hardhat-config");
|
||||
|
||||
// Run on testnet
|
||||
developmentChains.includes(network.name)
|
||||
? describe.skip
|
||||
: describe("FundMe", async function () {
|
||||
let fundMe;
|
||||
let deployer;
|
||||
const sendValue = ethers.utils.parseEther("1");
|
||||
// Assume already deployed
|
||||
// Assume on testnet, no need mock
|
||||
beforeEach(async function () {
|
||||
deployer = (await getNamedAccounts()).deployer;
|
||||
fundMe = await ethers.getContract("FundMe", deployer);
|
||||
});
|
||||
|
||||
it("allows people to fund and withdraw", async function () {
|
||||
const fundTxResponse = await fundMe.fund({ value: sendValue });
|
||||
await fundTxResponse.wait(1);
|
||||
const withdrawTxResponse = await fundMe.withdraw();
|
||||
await withdrawTxResponse.wait(1);
|
||||
|
||||
const endingFundMeBalance = await fundMe.provider.getBalance(
|
||||
fundMe.address,
|
||||
);
|
||||
console.log(
|
||||
endingFundMeBalance.toString() +
|
||||
" should equal 0, running assert equal...",
|
||||
);
|
||||
assert.equal(endingFundMeBalance.toString(), "0");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user