Does anyone know how to get the gas costs of a reversed transaction when testing with Hardhat / Chai?
I found out I can get the receipt object of a transaction, which holds the required data to calculate the total gas costs, like so:
const transaction = contract.connect(account).withdraw();
const receipt = await transaction.wait();
const transactionCosts = receipt.gasUsed.mul(
receipt.effectiveGasPrice
);
But now I have a transaction that gets reverted, for which I am also testing. Code:
await expect(
contract.connect(account).withdraw()
).to.be.revertedWith("Ownable: caller is not the owner");
Does anyone know how I get the gas costs (like in the first example) of the transaction in the second example?