Cheaper Gas v2
This commit is contained in:
+11
-11
@@ -25,18 +25,18 @@ describe("FundMe", function () {
|
||||
eth1 = ethers.utils.parseEther("1"); // Same 1 ETH
|
||||
describe("constructor", async function () {
|
||||
it("Set the aggregator priceFeedAddress correctly", async function () {
|
||||
const response = await fundMe.s_priceFeed(); // AggregatorV3Interface
|
||||
const response = await fundMe.getPriceFeed(); // AggregatorV3Interface
|
||||
//console.log("AggregatorV3Interface" + response);
|
||||
assert.equal(response, mockV3Aggregator.address);
|
||||
});
|
||||
it("Updated the amount funded data structure", async function () {
|
||||
await fundMe.fund({ value: eth1 });
|
||||
const response = await fundMe.s_addressToAmountFunded(deployer);
|
||||
const response = await fundMe.getAddressToAmountFunded(deployer);
|
||||
assert.equal(response.toString(), eth1.toString()); // Send 1 ETH
|
||||
});
|
||||
it("Adds funder to array of funders", async function () {
|
||||
await fundMe.fund({ value: eth1 });
|
||||
const funder = await fundMe.s_funders(0);
|
||||
const funder = await fundMe.getFunders(0);
|
||||
assert.equal(funder, deployer);
|
||||
});
|
||||
});
|
||||
@@ -80,10 +80,10 @@ describe("FundMe", function () {
|
||||
});
|
||||
|
||||
// Check if addr1 is added to funders
|
||||
expect(await fundMe.s_funders(0)).to.equal(addr1.address);
|
||||
expect(await fundMe.getFunders(0)).to.equal(addr1.address);
|
||||
// Check if the amount funded is recorded
|
||||
expect(
|
||||
await fundMe.s_addressToAmountFunded(addr1.address),
|
||||
await fundMe.getAddressToAmountFunded(addr1.address),
|
||||
).to.equal(ethers.utils.parseEther("1.0"));
|
||||
});
|
||||
|
||||
@@ -110,9 +110,9 @@ describe("FundMe", function () {
|
||||
}),
|
||||
).not.to.be.reverted;
|
||||
|
||||
expect(await fundMe.s_funders(0)).to.equal(addr1.address);
|
||||
expect(await fundMe.getFunders(0)).to.equal(addr1.address);
|
||||
expect(
|
||||
await fundMe.s_addressToAmountFunded(addr1.address),
|
||||
await fundMe.getAddressToAmountFunded(addr1.address),
|
||||
).to.equal(minFunding);
|
||||
});
|
||||
});
|
||||
@@ -191,11 +191,11 @@ describe("FundMe", function () {
|
||||
endingDeployerBalance.add(withdrawGasCost).toString(),
|
||||
);
|
||||
// Make a getter for storage variables
|
||||
await expect(fundMe.s_funders(0)).to.be.reverted;
|
||||
await expect(fundMe.getFunders(0)).to.be.reverted;
|
||||
|
||||
for (i = 1; i < 6; i++) {
|
||||
assert.equal(
|
||||
await fundMe.s_addressToAmountFunded(accounts[i].address),
|
||||
await fundMe.getAddressToAmountFunded(accounts[i].address),
|
||||
0,
|
||||
);
|
||||
}
|
||||
@@ -286,11 +286,11 @@ describe("FundMe", function () {
|
||||
endingDeployerBalance.add(withdrawGasCost).toString(),
|
||||
);
|
||||
// Make a getter for storage variables
|
||||
await expect(fundMe.s_funders(0)).to.be.reverted;
|
||||
await expect(fundMe.getFunders(0)).to.be.reverted;
|
||||
|
||||
for (i = 1; i < 6; i++) {
|
||||
assert.equal(
|
||||
await fundMe.s_addressToAmountFunded(accounts[i].address),
|
||||
await fundMe.getAddressToAmountFunded(accounts[i].address),
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user