Test done & debugging tool ok

This commit is contained in:
2024-08-06 04:41:40 +08:00
parent b7dcbb3039
commit 074260c945
4 changed files with 40 additions and 17 deletions
+13 -13
View File
@@ -121,29 +121,29 @@ describe("FundMe", function () {
beforeEach(async function () {
await fundMe.fund({ value: eth1 }); // Add 1 ETH first
});
it("Withdraw ETH from a single founder", async function () {
it("Withdraw ETH from a single funder", async function () {
/*
* Deployer = funder
* fundMe and replace with ethers, important to getBalance
*/
// Arrange
const startingFundMeBalance = await fundMe.provider.getBalance(
fundMe.address,
);
const startingDeployerBalance =
await fundMe.provider.getBalance(deployer);
const startingFundMeBalance = await fundMe.provider.getBalance(fundMe.address);
const startingDeployerBalance = await fundMe.provider.getBalance(deployer);
// Act
const transactionResponse = await fundMe.withdraw();
const transactionReceipt = await transactionResponse.wait(1);
const endingFundMeBalance = await fundMe.provider.getBalance(
fundMe.address,
);
const endingDeployerBalance =
await fundMe.provider.getBalance(deployer);
const endingFundMeBalance = await fundMe.provider.getBalance(fundMe.address);
const endingDeployerBalance = await fundMe.provider.getBalance(deployer);
//let gasCost = transactionReceipt;
const {gasUsed, effectiveGasPrice } = transactionReceipt; //gasUsed = "0x8b14"; effectiveGasPrice = "0x4e4814ec";
const gasCost = gasUsed.mul(effectiveGasPrice);
// Assert
assert.equal(endingFundMeBalance, 0);
//assert.equal(startingFundMeBalance.add(startingDeployerBalance), endingDeployerBalance.add(gasCost).toString())
assert.equal(startingFundMeBalance.add(startingDeployerBalance), endingDeployerBalance.add(gasCost).toString())
});
});
});