Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logs count in transaction receipt tests. (#5352) (#3803)
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {expect} from "chai"; | ||
import {Contract} from "ethers"; | ||
import hre, {ethers} from "hardhat"; | ||
|
||
const FUND = ethers.utils.parseUnits("1", "gwei"); | ||
|
||
async function getFee(hash: string) { | ||
const res = await ethers.provider.getTransactionReceipt(hash); | ||
return res.gasUsed.mul(res.effectiveGasPrice); | ||
} | ||
|
||
describe("Events and logs #parallel", function () { | ||
let contract: Contract; | ||
before(async function () { | ||
contract = await hre.deployContract("Event"); | ||
}); | ||
|
||
it("Should return 1 log whenever a function with one event is called @block-1", async function () { | ||
const tx = await contract.one_log(); | ||
const receipt = await ethers.provider.getTransactionReceipt(tx.hash); | ||
expect(receipt.logs.length).to.be.eq(1); | ||
}); | ||
|
||
it("Should return 2 logs whenever a function with two events is called @block-1", async function () { | ||
const tx = await contract.two_logs(); | ||
const receipt = await ethers.provider.getTransactionReceipt(tx.hash); | ||
expect(receipt.logs.length).to.be.eq(2); | ||
}); | ||
}); |