Developer Highlights #6 - "Matchstick - Unit testing for subgraphs"

In Developer Highlights #6 I had the pleasure of speaking with Petko Pavlovski @AxiomaticAardvark from Limechain. Limechain delivers professional Blockchain & DLT services for enterprises and entrepreneurs.

Many of you already know Petko from the Discord community, as he frequently helps other members. Petko has been working on Matchstick - a unit testing framework for The Graph. This is a gamechanger for subgraph development! You can now test changes to your code in mere milliseconds.

In this video we cover everything you need to know about Matchstick. From installing to writing different tests.

Watch the full video, or jump straight to each topic using the timestamps below the video.

00:00 Intro - Limechain

02:36 Why use Matchstick?
03:45 Example Subgraph
05:53 Installing Matchstick

Mock Event
08:11 Writing a test
09:55 Instantiating a mock event
12:38 Calling a handler
13:20 Writing an assertion
14:30 Clearing the store
14:58 Export runTests() in the mappings
15:28 Running a test
16:54 What a failed test look like

Hydrated Store
17:36 Hydrating the store with a certain state
19:00 Running a test on the hydrated store

Mock Function
19:38 Github repository with examples
20:18 Example mapping
21:09 Mocking a smart contract function
24:06 Calling the mocked function
26:55 Forcing a function to revert

28:44 Shell Script for “Build and Test”
29:19 Test execution time
29:55 Logging
31:38 Assert helper functions
32:42 Different logging functions

Other Topics
33:48 Event metadata
35:41 Matchstick channel in The Graph Discord
36:01 Github improvement board

Matchstick Repository
Demo Repository
Matchstick Tutorial

If you have any questions about Matchstick, we encourage you to post your questions below.