2021-09-17 12:46:05 +00:00
|
|
|
# graph-node
|
2021-10-27 09:13:48 +00:00
|
|
|
|
|
|
|
## Test
|
|
|
|
|
|
|
|
1. Run `yarn` to install all dependencies.
|
|
|
|
|
|
|
|
2. Create .env file
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ cp .env.example .env
|
|
|
|
```
|
|
|
|
|
2022-04-27 10:07:13 +00:00
|
|
|
3. Run `yarn build:example` to build the wasm files.
|
2021-10-27 09:13:48 +00:00
|
|
|
|
2022-04-27 10:07:13 +00:00
|
|
|
4. Run `yarn test`.
|
2021-11-23 10:45:42 +00:00
|
|
|
|
|
|
|
## Run
|
|
|
|
|
|
|
|
* Compare query results from two different GQL endpoints:
|
2021-11-26 11:07:33 +00:00
|
|
|
|
2021-11-23 10:45:42 +00:00
|
|
|
* In a config file (sample: `environments/compare-cli-config.toml`):
|
|
|
|
|
|
|
|
* Specify the two GQL endpoints in the endpoints config.
|
|
|
|
|
|
|
|
* Specify the query directory in queries config or pass as an arg. to the CLI.
|
|
|
|
|
|
|
|
* Example:
|
|
|
|
|
|
|
|
```
|
|
|
|
[endpoints]
|
|
|
|
gqlEndpoint1 = "http://localhost:8000/subgraphs/name/example1"
|
|
|
|
gqlEndpoint2 = "http://localhost:3008/graphql"
|
2021-11-26 11:07:33 +00:00
|
|
|
|
2021-11-23 10:45:42 +00:00
|
|
|
[queries]
|
|
|
|
queryDir = "../graph-test-watcher/src/gql/queries"
|
|
|
|
```
|
|
|
|
|
|
|
|
* Fire a query and get the diff of the results from the two GQL endpoints:
|
|
|
|
|
|
|
|
```bash
|
2021-12-01 11:04:56 +00:00
|
|
|
./bin/compare-entity --config-file <config-file-path> --query-dir [query-dir] --query-name <query-name> --block-hash <block-hash> --entity-id <entity-id> --raw-json [true | false]
|
2021-11-23 10:45:42 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
* `config-file`(alias: `cf`): Configuration file path (toml) (required).
|
|
|
|
* `query-dir`(alias: `qf`): Path to queries directory (defualt: taken from the config file).
|
|
|
|
* `query-name`(alias: `q`): Query to be fired (required).
|
|
|
|
* `block-hash`(alias: `b`): Block hash (required).
|
|
|
|
* `entity-id`(alias: `i`): Entity Id (required).
|
|
|
|
* `raw-json`(alias: `j`): Whether to print out a raw diff object (default: `false`).
|
2021-11-26 11:07:33 +00:00
|
|
|
|
2021-11-23 10:45:42 +00:00
|
|
|
Example:
|
|
|
|
|
|
|
|
```bash
|
2021-12-01 11:04:56 +00:00
|
|
|
./bin/compare-entity --config-file environments/compare-cli-config.toml --query-name author --block-hash 0xceed7ee9d3de97c99db12e42433cae9115bb311c516558539fb7114fa17d545b --entity-id 0xdc7d7a8920c8eecc098da5b7522a5f31509b5bfc
|
2021-11-23 10:45:42 +00:00
|
|
|
```
|
2021-11-26 11:07:33 +00:00
|
|
|
|
2021-11-23 10:45:42 +00:00
|
|
|
* The program will exit with code `1` if the query results are not equal.
|
2022-08-08 10:28:13 +00:00
|
|
|
|
|
|
|
* For comparing queries in a range of blocks:
|
|
|
|
|
2022-10-04 05:48:55 +00:00
|
|
|
* Config file should have the names of queries to be fired along with the corresponding entity names.
|
2022-08-08 10:28:13 +00:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[queries]
|
|
|
|
queryDir = "../graph-test-watcher/src/gql/queries"
|
2022-10-04 05:48:55 +00:00
|
|
|
[queries.names]
|
|
|
|
author = "Author"
|
|
|
|
blog = "Blog"
|
2022-08-08 10:28:13 +00:00
|
|
|
```
|
2022-10-04 05:48:55 +00:00
|
|
|
|
|
|
|
The queries will be fired if the corresponding entities are updated.
|
2022-10-19 09:54:14 +00:00
|
|
|
|
2022-08-08 10:28:13 +00:00
|
|
|
* Run the CLI:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
./bin/compare-blocks --config-file environments/compare-cli-config.toml --start-block 1 --end-block 10
|
|
|
|
```
|
2022-10-19 09:54:14 +00:00
|
|
|
|
2022-08-17 13:41:40 +00:00
|
|
|
* For comparing entities after fetching updated entity ids from watcher database:
|
2022-08-08 10:28:13 +00:00
|
|
|
|
2022-08-17 13:41:40 +00:00
|
|
|
* Set the watcher config file path and entities directory.
|
2022-08-08 10:28:13 +00:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[endpoints]
|
|
|
|
gqlEndpoint1 = "http://localhost:8000/subgraphs/name/example1"
|
|
|
|
gqlEndpoint2 = "http://localhost:3008/graphql"
|
|
|
|
|
|
|
|
[queries]
|
|
|
|
queryDir = "../graph-test-watcher/src/gql/queries"
|
2022-10-04 05:48:55 +00:00
|
|
|
[queries.names]
|
|
|
|
author = "Author"
|
|
|
|
blog = "Blog"
|
2022-10-19 09:54:14 +00:00
|
|
|
|
2022-08-17 13:41:40 +00:00
|
|
|
[watcher]
|
|
|
|
configPath = "../../graph-test-watcher/environments/local.toml"
|
|
|
|
entitiesDir = "../../graph-test-watcher/dist/entity/*"
|
|
|
|
```
|
2022-10-19 09:54:14 +00:00
|
|
|
|
|
|
|
* To verify `diff` State state generated at each block, set the watcher endpoint and `verifyState` flag to true
|
2022-08-17 13:41:40 +00:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[watcher]
|
|
|
|
configPath = "../../graph-test-watcher/environments/local.toml"
|
|
|
|
entitiesDir = "../../graph-test-watcher/dist/entity/*"
|
|
|
|
endpoint = "gqlEndpoint2"
|
|
|
|
verifyState = true
|
2022-08-08 10:28:13 +00:00
|
|
|
```
|
2022-10-19 09:54:14 +00:00
|
|
|
|
2022-08-08 10:28:13 +00:00
|
|
|
* Run the CLI with `fetch-ids` flag set to true:\
|
|
|
|
|
|
|
|
```bash
|
|
|
|
./bin/compare-blocks --config-file environments/compare-cli-config.toml --start-block 1 --end-block 10 --fetch-ids
|
|
|
|
```
|