I'm writing the test cases for a contract, and I have a problem trying to match the balance, because of the transaction gas. what is the correct way to do it?
it("should allow the owner of the campaign to withdraw funds if the campaign is successful", async () => {
const target = ethers.utils.parseEther("1");
await contract.connect(aliceAccount).createCampaign(
"Test Campaign",
"Test Description",
ethers.utils.parseEther("10"),
"testimage.jpg"
);
// Bob and Alice donate to the campaign
await contract
.connect(bobAccount)
.donateToCampaign(0, { value: ethers.utils.parseEther("5") });
await contract
.connect(johnAccount)
.donateToCampaign(0, { value: ethers.utils.parseEther("5") });
// check if the campaign has reached its target
const campaign = await contract.campaigns(0);
expect(campaign.amountCollected).to.equal(ethers.utils.parseEther("10"));
expect(campaign.status).to.equal(2);
// get the balance of the owner before withdrawing funds
const balanceBefore = await ethers.provider.getBalance(aliceAccount.address);
// call the withdrawFunds function
const tx = await contract.connect(aliceAccount).withdrawFunds(0);
// get the balance of the owner after withdrawing funds
const balanceAfter = await ethers.provider.getBalance(aliceAccount.address);
// WHAT IS THE COORECT WAY TO CHECK THIS? the problem is the gas
expect(balanceAfter == balanceBefore + 10 ether )
});