Test done & debugging tool ok
This commit is contained in:
parent
b7dcbb3039
commit
074260c945
25
.vscode/launch.json
vendored
Normal file
25
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${file}",
|
||||
|
||||
"args": ["test", "--network", "localhost"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"runtimeArgs": ["--inspect-brk"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"outputCapture": "std",
|
||||
"autoAttachChildProcesses": true
|
||||
}
|
||||
]
|
||||
}
|
@ -7,19 +7,17 @@
|
||||
"license": "Unlicense",
|
||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
|
||||
"devDependencies": {
|
||||
|
||||
|
||||
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
|
||||
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
|
||||
"@nomicfoundation/hardhat-ethers": "^3.0.0",
|
||||
"@nomicfoundation/hardhat-ignition": "^0.15.0",
|
||||
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
|
||||
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
|
||||
"@nomicfoundation/hardhat-network-helpers": "^1.0.11",
|
||||
"@nomicfoundation/hardhat-verify": "^2.0.0",
|
||||
"@typechain/ethers-v6": "^0.5.0",
|
||||
"@typechain/hardhat": "^9.0.0",
|
||||
|
||||
|
||||
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13",
|
||||
"@nomiclabs/hardhat-etherscan": "^3.0.0",
|
||||
"@nomiclabs/hardhat-waffle": "^2.0.2",
|
||||
|
@ -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())
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -684,7 +684,7 @@
|
||||
fs-extra "^10.0.0"
|
||||
prompts "^2.4.2"
|
||||
|
||||
"@nomicfoundation/hardhat-network-helpers@^1.0.0":
|
||||
"@nomicfoundation/hardhat-network-helpers@^1.0.11":
|
||||
version "1.0.11"
|
||||
resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-network-helpers/-/hardhat-network-helpers-1.0.11.tgz#64096829661b960b88679bd5c4fbcb50654672d1"
|
||||
integrity sha512-uGPL7QSKvxrHRU69dx8jzoBvuztlLCtyFsbgfXIwIjnO3dqZRz2GNMHJoO3C3dIiUNM6jdNF4AUnoQKDscdYrA==
|
||||
|
Loading…
Reference in New Issue
Block a user