diff --git a/tests/EvmAcceptanceTests/contracts/Event.sol b/tests/EvmAcceptanceTests/contracts/Event.sol index 252859430e..45318fee29 100644 --- a/tests/EvmAcceptanceTests/contracts/Event.sol +++ b/tests/EvmAcceptanceTests/contracts/Event.sol @@ -9,9 +9,12 @@ contract Event { event Log(address indexed sender, string message); event AnotherLog(); - function test() public { + function one_log() public { + emit Log(msg.sender, "Hello World!"); + } + + function two_logs() public { emit Log(msg.sender, "Hello World!"); - emit Log(msg.sender, "Hello EVM!"); emit AnotherLog(); } } \ No newline at end of file diff --git a/tests/EvmAcceptanceTests/test/EventsLogs.ts b/tests/EvmAcceptanceTests/test/EventsLogs.ts new file mode 100644 index 0000000000..9acf10a140 --- /dev/null +++ b/tests/EvmAcceptanceTests/test/EventsLogs.ts @@ -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); + }); +});