π
Quick Start The release binary comes in three flavours - for macOS, Linux and Windows. To add Matchstick to your subgraph project just open up a terminal, navigate to the root folder of your project and simply run graph test
- it downloads the latest Matchstick binary and runs the specified test or all tests in a test folder (or all existing tests if no datasource flag is specified). Example usage: graph test Gravity
.
macOS ο£Ώ
brew install postgresql
π§
Linux
sudo apt install postgresql
Windows
choco install postgresql12
Install dependencies
In order to use the test helper methods and run the tests, you will need to install the following dependencies:
yarn add matchstick-as
Now you can jump straight to the examples in our demo-subgraph and start your journey in Subgraph unit testing!
Building from source
Prerequisites
To build and run Matchstick you need to have the following installed on your system:
- Rust - How to install Rust
- PostgreSQL β PostgreSQL Downloads
Setup
Clone this repository and run cargo build
. If that executes successfully congratulations
NOTE: You may encounter an error, related to missing libpq
dependencies on your system. In that case - install the missing dependencies (listed in the error log) with your package manager.
π―
Next steps There is a lot of room for improvements to Matchstick. We're trying to gather as much feedback from subgraph developers as we can, to understand how we can solve the problems they face when building subgraphs, as well as how we can make the overall testing process as smooth and streamlined as possible.
There's a GitHub project board where we keep track of day to day work which you can check out here.
You can check out the full list of tasks here.
π»
Technologies used
The Matchstick framework is built in Rust and acts as a wrapper for the generated WebAssembly module that contains the mappings and the unit tests. It passes the host function implementations down to the module, to be used in the tests (and in the mappings if needed). The framework also acts as a proxy for structs defined in the graph-node repo, because it needs to pass down all the usual imports, as well as a few bonus/mocked ones glued on top.
Matchstick also relies on a helper library - matchstick-as, written in AssemblyScript and used as an import in the unit tests.