I was writing test script for a contract. I am stuck at a point where there is a claim function. whenever a user calls it, he gets the claimable ether, whatever available. The problem is when I compare the balance before and after calling the claim function, it doesn't match. One reason I can think of is the gas price that is being deducted. If this is the reason then how can I include the gas price amount in the calculation? What can be other reasons?
This is the test case.
it("user1 can withdraw their funds", async () => {
let balance1 = await ethers.provider.getBalance(participant1.address);
await expect(bounty.connect(participant1).claimPrize()).to.be.fulfilled;
expect(await ethers.provider.getBalance(participant1.address)).to.be.equal(balance1.add(ethers.utils.parseEther("2")));
})