Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add rpc test to match logIndex #284

Merged
merged 5 commits into from
Jul 23, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion test/RpcCompatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const chai = require('chai');
const { ethers, network } = require('hardhat');
const {
utils: { hexValue, getAddress, keccak256 },
utils: { hexValue, getAddress, keccak256, id },
Wallet,
BigNumber,
} = ethers;
Expand Down Expand Up @@ -384,6 +384,33 @@ describe('RpcCompatibility', () => {
});
});

it('should match the fetched logIndex value', async function () {
blockchainguyy marked this conversation as resolved.
Show resolved Hide resolved
const amount = 100;

const receipt = await rpcCompatibilityContract.updateValue(amount).then((tx) => tx.wait());
const logsFromReceipt = receipt.logs;

const eventSignature = id('ValueUpdated(uint256)');
const expectedEvent = logsFromReceipt.find((log) => log.topics[0] === eventSignature);
expect(expectedEvent, 'ValueUpdated event not found in logs from tx receipt').to.exist.and.to.not.be.null;

const blockNumber = '0x' + parseInt(receipt.blockNumber).toString(16);
const logsFromGetLogs = await provider.send('eth_getLogs', [
{
fromBlock: blockNumber,
toBlock: blockNumber,
},
]);

const matchingEvent = logsFromGetLogs.find((log) => log.topics[0] === eventSignature);
expect(matchingEvent, 'ValueUpdated event not found in logs from eth_getLogs').to.not.be.null;

expect(parseInt(expectedEvent.logIndex)).to.equal(
parseInt(matchingEvent.logIndex),
'Log index mismatch between tx receipt and eth_getLogs',
);
});

describe('eip-1559 supported rpc methods', () => {
if (!isHardhat) {
it('should support RPC method eth_maxPriorityFeePerGas', async () => {
Expand Down
Loading