|
1 | 1 | # Voting Tools (Rust)
|
2 | 2 |
|
3 |
| -This tool generates voting power info from a db-sync instance. |
| 3 | +This tool generates voting power info from a `cardano-db-sync` instance. |
4 | 4 |
|
5 | 5 | Example usage:
|
6 | 6 |
|
7 |
| -``` |
| 7 | +```sh |
8 | 8 | snapshot-tool --db postgres --db-user postgres --db-host localhost --out-file output.json
|
9 | 9 | ```
|
10 | 10 |
|
11 |
| -## Building |
12 |
| - |
13 |
| -Building with nix should be straightforward, simply enter a dev environment with `nix develop`, then run `cargo build` to build. |
14 |
| - |
15 |
| -## Testing |
16 |
| - |
17 |
| -To run tests, run `cargo test`. Note, these tests include database tests, which require a running postgres instance to connect to. If you want to run only non-database tests, run `cargo test --no-default-features` |
| 11 | +To get a full list of available arguments run: |
18 | 12 |
|
19 |
| -### Database tests |
| 13 | +```sh |
| 14 | +snapshot-tool --help |
| 15 | +``` |
20 | 16 |
|
21 |
| -Database tests perform predefined queries against a test database. If the results don't match the snapshots, the test fails. This requires having the correct data in your database. The current test data can be found [here](https://updates-cardano-testnet.s3.amazonaws.com/cardano-db-sync/index.html#13/). |
| 17 | +## Building |
22 | 18 |
|
23 |
| -There are also "reference database tests", which populate a mock database with fake data, run queries against them, and check the results. These do not require the preset test data, as the correct data is created in the test. |
| 19 | +Building with nix should be straightforward, simply enter a dev environment with `nix develop`, then run `cargo build -p voting_tools_rs` to build. |
24 | 20 |
|
25 |
| -Once you have this database set up, create a file at `<project_root>/test_db.json`, which contains credentials to connect to this database, for example: |
| 21 | +## Testing |
26 | 22 |
|
27 |
| -```json |
28 |
| -{ |
29 |
| - "host": "localhost", |
30 |
| - "name": "database_name", |
31 |
| - "user": "username", |
32 |
| - "password": "password" |
33 |
| -} |
34 |
| -``` |
| 23 | +To run tests, run `cargo test -p voting_tools_rs`. |
35 | 24 |
|
36 |
| -(Note, password is optional). |
| 25 | +## Spin up cardano-db-sync |
37 | 26 |
|
38 |
| -From there, running `cargo test` will run database tests as well as regular tests. If tests pass, great! |
| 27 | +To sucessufully run the `snapshot-tool` it is needed to have a running [`cardano-db-sync`](https://github.com/IntersectMBO/cardano-db-sync) instance. |
39 | 28 |
|
40 |
| -If not, you need to review the changes. It's possible that you intended to change the result of a query. Use `cargo insta review` to go through all failed tests and mark them as "intended" or not. |
| 29 | +[Here](https://github.com/IntersectMBO/cardano-db-sync/blob/master/doc/building-running.md) you can found a guide how to build and run `cardano-db-sync`. |
0 commit comments