-
Notifications
You must be signed in to change notification settings - Fork 263
Attempt to add integration tests which simulate graph calculations #1612
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
base: develop
Are you sure you want to change the base?
Conversation
Hardhat Unit Tests Coverage SummaryDetailsDiff against masterResults for commit: a2426bd Minimum allowed coverage is ♻️ This comment has been updated with latest results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a comprehensive Graph simulator and integration test suite to validate entity computation in the Lido subgraph. The implementation simulates event-driven entity updates from transaction events and compares the resulting state against on-chain data to detect drift or bugs in the subgraph mappings.
Key changes:
- Created a TypeScript Graph simulator that processes Lido events and generates entities matching the subgraph's behavior
- Implemented integration tests with a 32-action scenario covering deposits, transfers, oracle reports, withdrawals, and V3 vault operations
- Added utilities for state capture, event extraction, and entity validation
Reviewed changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/graph/simulator/index.ts | Main simulator entry point with GraphSimulator class and processTransaction function |
| test/graph/simulator/handlers/lido.ts | Event handlers for Lido events (ETHDistributed, Submitted, Transfer, SharesBurnt, V3 events) |
| test/graph/simulator/entities.ts | Entity type definitions (TotalReward, Totals, Shares, LidoTransfer, etc.) |
| test/graph/simulator/store.ts | In-memory entity store with load/save operations |
| test/graph/simulator/helpers.ts | APR calculation and helper functions |
| test/graph/utils/event-extraction.ts | Event parsing and extraction utilities |
| test/graph/utils/state-capture.ts | Chain state capture functions |
| test/graph/entities-scenario.integration.ts | Comprehensive 32-action integration test scenario |
| test/graph/README.md | Documentation for the test framework and approach |
| package.json | Updated test commands for integration tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Note: totalShares is not directly updated here as it's handled by the SharesBurnt event. | ||
| * This handler only updates totalPooledEther from contract. |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states totalShares is handled by SharesBurnt, but according to the V3 event handler pattern and line 1041's implementation comment, this is describing ExternalSharesBurnt which only updates totalPooledEther. The comment should clarify that the accompanying SharesBurnt event (not ExternalSharesBurnt) updates totalShares.
| * Note: totalShares is not directly updated here as it's handled by the SharesBurnt event. | |
| * This handler only updates totalPooledEther from contract. | |
| * Note: totalShares is not directly updated here; it is updated by the accompanying | |
| * SharesBurnt event. This handler only updates totalPooledEther from the contract. |
| * - V3 external shares mint: 5+ | ||
| * - V3 external shares burn: 5+ |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The target numbers don't match the minimum validation on lines 1019-1024. The comment claims '6+' deposits and '5+' for other actions, but the test validates '>= 6' deposits, '>= 5' transfers, '>= 7' reports, '>= 5' withdrawals, '>= 4' mints, and '>= 4' burns. Update the comment to match the actual validation: 'V3 external shares mint: 4+' and 'V3 external shares burn: 4+'.
| * - V3 external shares mint: 5+ | |
| * - V3 external shares burn: 5+ | |
| * - V3 external shares mint: 4+ | |
| * - V3 external shares burn: 4+ |
|
|
||
| File `entities-scenario.integration.ts`. | ||
|
|
||
| **Minimum targets:** 6 deposits, 5 transfers, 7 oracle reports, 5 withdrawal requests, 4 V3 mints, 4 V3 burns. |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line correctly states the minimum targets, which matches the test validation. However, it contradicts the comment in entities-scenario.integration.ts lines 33-38 which states '5+ V3 mints' and '5+ V3 burns'. The README is correct; the test file comment should be updated.
| "test:watch": "SKIP_GAS_REPORT=true SKIP_CONTRACT_SIZE=true hardhat watch test", | ||
| "test:integration": "MODE=forking hardhat test test/integration/**/*.ts", | ||
| "test:integration": "yarn test:integration:helper test/integration/**/*.ts", | ||
| "test:integration:helper": "SKIP_GAS_REPORT=true SKIP_CONTRACT_SIZE=true SKIP_INTERFACES_CHECK=true SKIP_GAS_REPORT=true MODE=forking hardhat test ", |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SKIP_GAS_REPORT is duplicated in the environment variables. Remove one occurrence.
|
|
||
| ### ❌ Missing in Simulator | ||
|
|
||
| 1. **SharesBurnt handling** - Real graph manually processes SharesBurnt events within handleETHDistributed; simulator has placeholder but does not handle this yet. |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This document states SharesBurnt handling is missing in the simulator, but the code in test/graph/simulator/handlers/lido.ts lines 208-215 shows that SharesBurnt events ARE handled within handleETHDistributed (findAllEventsByName and handleSharesBurnt calls). The documentation should be updated to reflect the current implementation status.
No description provided.