Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update snapshot-tool readme | NPG-000 #696

Merged
merged 2 commits into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions src/voting-tools-rs/README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,29 @@
# Voting Tools (Rust)

This tool generates voting power info from a db-sync instance.
This tool generates voting power info from a `cardano-db-sync` instance.

Example usage:

```
```sh
snapshot-tool --db postgres --db-user postgres --db-host localhost --out-file output.json
```

## Building

Building with nix should be straightforward, simply enter a dev environment with `nix develop`, then run `cargo build` to build.

## Testing

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`
To get a full list of available arguments run:

### Database tests
```sh
snapshot-tool --help
```

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/).
## Building

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.
Building with nix should be straightforward, simply enter a dev environment with `nix develop`, then run `cargo build -p voting_tools_rs` to build.

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:
## Testing

```json
{
"host": "localhost",
"name": "database_name",
"user": "username",
"password": "password"
}
```
To run tests, run `cargo test -p voting_tools_rs`.

(Note, password is optional).
## Spin up cardano-db-sync

From there, running `cargo test` will run database tests as well as regular tests. If tests pass, great!
To sucessufully run the `snapshot-tool` it is needed to have a running [`cardano-db-sync`](https://github.com/IntersectMBO/cardano-db-sync) instance.

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.
[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`.
Loading