Subgraph Testing with Matchstick: Unit Test Guide for The Graph

Added:

Setup
Test Setup
Write Test
Run Test

Setup

0:00
Playing Section
  • 1

    Introduces matchstick for testing subgraph handlers in a sandbox.

  • 2

    Explains the demo subgraph and focuses on the handleNewGravatar event handler.

  • 3

    Adds matchstick library and test script to the project.

Fundamental concepts of Web3 development, specifically how Ethereum smart contracts emit events to log state changes.
The architecture of The Graph protocol, including the roles of the manifest (subgraph.yaml), GraphQL schema, and AssemblyScript mappings.
Basic proficiency in AssemblyScript or TypeScript, as mapping logic and Matchstick tests are written in these languages.
General principles of unit testing, such as assertions, test cases, and the concept of mocking external dependencies.
Advanced Matchstick testing techniques, including mocking Ethereum smart contract read-only calls (mockContractCall) and IPFS file data sources.
Integrating Matchstick unit tests into Continuous Integration (CI/CD) pipelines, such as GitHub Actions, for automated subgraph verification.
Testing subgraph resilience against blockchain reorgs (reorganizations) and handling complex multi-contract event coordination.
Querying and validating indexed data via GraphQL in local or staging environments before deploying to the decentralized network.
1.6K views20likes7:05@GraphProtocolOriginal Release: 2021-12-22

Matchstick is a testing framework for The Graph Protocol that enables developers to write unit tests for subgraph event and function handlers by creating mock events in a sandbox environment, then verifying that handler functions correctly transform event data into stored entities using assertion methods.