Skip to content

Commit 317d2d4

Browse files
authored
feat: Update snapshot-tool readme | NPG-000 (#696)
# Description Updating a stale `snapshot-tool` Readme. Providing a guides how to build and run `snapshot-tool` itself and referencing to the `cardano-db-sync` docs for spin upping local instance of the database.
1 parent b05c57d commit 317d2d4

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

src/voting-tools-rs/README.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,29 @@
11
# Voting Tools (Rust)
22

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.
44

55
Example usage:
66

7-
```
7+
```sh
88
snapshot-tool --db postgres --db-user postgres --db-host localhost --out-file output.json
99
```
1010

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:
1812

19-
### Database tests
13+
```sh
14+
snapshot-tool --help
15+
```
2016

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
2218

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.
2420

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
2622

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`.
3524

36-
(Note, password is optional).
25+
## Spin up cardano-db-sync
3726

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.
3928

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

Comments
 (0)