Project Ready

This commit is contained in:
2024-08-06 20:52:02 +08:00
parent a76b612818
commit d1b444988e
7 changed files with 420 additions and 280 deletions
+36
View File
@@ -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");
});
});