Skip to content

Gnd test improvements#6442

Open
dimitrovmaksim wants to merge 6 commits intographprotocol:masterfrom
dimitrovmaksim:gnd-test-improvements
Open

Gnd test improvements#6442
dimitrovmaksim wants to merge 6 commits intographprotocol:masterfrom
dimitrovmaksim:gnd-test-improvements

Conversation

@dimitrovmaksim
Copy link
Member

This pull request introduces improvements and new features to the gnd test framework:

  • Partial support for transaction receipts in test handlers: receipt.logs is now populated and grouped by txHash, while other fields are hardcoded stubs. Handlers without receipt: true continue to receive null receipts. Documentation details grouping rules and limitations.
  • Added MockIpfsClient and MockArweaveResolver implementations, allowing tests to pre-load mock file data and report missing CIDs or txIds as clear failures after sync.

Documentation and Troubleshooting

  • Expanded documentation for transaction receipt mocking, including grouping logic, example JSON, and limitations. Updated the feature matrix to reflect partial support.
  • Added a troubleshooting section explaining the 60-second timeout caused by unmocked eth_call, including symptoms, fixes, and plans for future improvements.

Build mock receipts from block events and attach them to log triggers.
Events sharing the same txHash share a receipt whose logs contains all
their logs in declaration order; events without an explicit txHash each
get a unique auto-generated hash and their own single-log receipt.

Receipts are only attached to logs whose event selector (topic0) matches
a handler that declares receipt: true in the manifest, mirroring
production behaviour where graph-node only fetches receipts from the RPC
for those handlers. The selector is computed using the same normalisation
as graph-node's MappingEventHandler::topic0() to handle the manifest's
indexed-before-type convention (e.g. Transfer(indexed address,...)).

Most receipt fields (gas, from, to, status) are hardcoded stubs; only
receipt.logs reflects the actual test data.
Replaces the dummy IpfsRpcClient with a MockIpfsClient that serves
pre-loaded CID → bytes from a "files" array in test JSON files.
Missing CIDs are reported with a clear error instead of a 60-second
timeout. Also adds IpfsResponse::for_test() helper and documents the
unmocked eth_call timeout in the troubleshooting guide.
Introduces `MockArweaveResolver` and the `arweaveFiles` schema field so
`gnd test` can serve pre-loaded Arweave content without hitting the
network. Unresolved tx IDs are collected and reported as a clear test
failure, mirroring the existing IPFS mock behaviour.
Add IPFS and Arweave file data source test fixtures and split the
monolithic gnd_test fixture into four focused subgraphs:

- token/            ERC20 events, eth_call mocking, dynamic templates
- blocks/           Block handlers (every, once, polling filters)
- receipts/         Transaction receipts (receipt: true handlers)
- file-data-sources/ IPFS and Arweave file data sources

Each fixture is a standalone subgraph with its own schema, mappings,
ABIs, and test JSON files. The Rust test harness is updated to use a
generic setup_fixture(name) helper, with one test function per fixture.
@dimitrovmaksim dimitrovmaksim self-assigned this Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant