feat(testing): add readme for testing
This commit is contained in:
28
substreams/ethereum-template/test_assets.yaml
Normal file
28
substreams/ethereum-template/test_assets.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
substreams_yaml_path: ./substreams.yaml
|
||||
protocol_type_names:
|
||||
- "type_name_1"
|
||||
- "type_name_2"
|
||||
tests:
|
||||
- name: test_pool_creation
|
||||
start_block: 123
|
||||
stop_block: 456
|
||||
expected_state:
|
||||
protocol_components:
|
||||
- id: "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7"
|
||||
tokens:
|
||||
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
||||
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
||||
- "0x6b175474e89094c44da98b954eedeac495271d0f"
|
||||
static_attributes:
|
||||
creation_tx: "0x20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6"
|
||||
- name: test_something_else
|
||||
start_block: 123
|
||||
stop_block: 456
|
||||
expected_state:
|
||||
protocol_components:
|
||||
- id: "0xdc24316b9ae028f1497c275eb9192a3ea0f67022"
|
||||
tokens:
|
||||
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
|
||||
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
|
||||
static_attributes:
|
||||
creation_tx: "0xfac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa"
|
||||
53
testing/README.md
Normal file
53
testing/README.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Substreams Testing
|
||||
|
||||
We know testing your Substreams modules can be a pain. So, our goal here is to provide a quick and easy way to run end-to-end tests.
|
||||
|
||||
Our script will build the `.spkg` for your Substreams module, index the specified block range, and check if the expected state has been correctly indexed in PostgreSQL.
|
||||
|
||||
## How to Test
|
||||
|
||||
Here's what you need to do:
|
||||
|
||||
1. Get the latest version of our indexer.
|
||||
2. Define your tests and expected state.
|
||||
3. Run the testing script.
|
||||
|
||||
### Get the Latest Version of Tycho (Indexer)
|
||||
|
||||
We don't have a direct download link yet. Please reach out to us to get the latest version. Once you have it, place it in the `/testing/` folder.
|
||||
|
||||
### Define Your Tests
|
||||
|
||||
Define all your tests in a `yaml` file. You can find a template in `substreams/ethereum-template/test_assets.yaml`.
|
||||
|
||||
You'll need to:
|
||||
|
||||
- Point to the target substreams config file.
|
||||
- Specify the expected protocol types.
|
||||
- Define your tests.
|
||||
|
||||
For each test, the script will index all blocks between `start-block` and `stop-block` and check that the indexed state matches the expected state.
|
||||
|
||||
### Run the Script
|
||||
|
||||
Once everything is set up, run our script using the CLI.
|
||||
|
||||
First, you need a local postgres database
|
||||
|
||||
```bash
|
||||
docker-compose up -d db
|
||||
```
|
||||
|
||||
Then export an environment variable for RPC connection
|
||||
|
||||
```bash
|
||||
export RPC_URL=your-chain-rpc
|
||||
```
|
||||
|
||||
And finally run the testing script
|
||||
|
||||
```bash
|
||||
python testing/cli.py --test_yaml_path "./substreams/your-substreams-folder/test_assets.yaml"
|
||||
```
|
||||
|
||||
You can get the available CLI flags using `--help`
|
||||
Reference in New Issue
Block a user