Test done & debugging tool ok
This commit is contained in:
+13
-13
@@ -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())
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user