-
Notifications
You must be signed in to change notification settings - Fork 161
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
docs: RPC test snapshot #5144
Merged
Merged
docs: RPC test snapshot #5144
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
016107d
docs: RPC test snapshot
hanabi1224 8585b67
run through grammarly
hanabi1224 2d71d1d
Merge remote-tracking branch 'origin/main' into hm/rpc-snapshot-docs
hanabi1224 5cd0d6f
Merge remote-tracking branch 'origin/main' into hm/rpc-snapshot-docs
hanabi1224 2cb8e9b
resolve comments
hanabi1224 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: RPC Test Snapshots | ||
sidebar_position: 2 | ||
--- | ||
|
||
This document describes how to generate and use RPC test snapshots. An RPC test snapshot contains the name of the RPC method, the request payload, the desired response, and the minimal database entries for replaying the request. Thus, it can be used as a regression test or a unit test for an RPC method. | ||
|
||
### Generate RPC test dumps | ||
|
||
An RPC test dump contains the name of the RPC method, the request payload, and the response of an RPC call. It is used to dump a minimal database snapshot and replay the request in a subsequent process. | ||
|
||
To generate test dumps, add `--dump-dir [PATH]` to `forest-tool api compare` command. e.g., `forest-tool api compare forest_snapshot_calibnet_2025-01-15_height_2320334.forest.car.zst --dump-dir /var/tmp/rpc-dump` | ||
|
||
### Generate RPC test snapshots | ||
|
||
As described above, an RPC test snapshot is generated from an RPC test dump and includes the extra minimal database snapshot in Forest CAR format. | ||
|
||
The `forest-tool api generate-test-snapshot` command is for this purpose, note that it takes the database path of the Forest daemon against which the `forest-tool api compare` command in the previous step is run, to dump the minimal database snapshot. e.g. `forest-tool api generate-test-snapshot --db ~/.local/share/forest/calibnet/0.23.3 --chain calibnet --out-dir /var/tmp/rpc-snapshots /var/tmp/test-dumps/filecoin_stategetallallocations*.json` | ||
|
||
### (Optional) compress the test snapshots | ||
|
||
A test snapshot generated in the previous step is in JSON format, for easier inspection of the content. The Forest tool set supports `.zst` archives of test snapshots for better disk usage and network bandwidth efficiency. Just run `zstd /var/tmp/rpc-snapshots/*.json` | ||
|
||
### Verify the test snapshots | ||
|
||
`forest-tool api test /var/tmp/rpc-snapshots/*.json` or `forest-tool api test /var/tmp/rpc-snapshots/*.zst`. As mentioned above, both `.json` and `.json.zst` formats are supported. | ||
|
||
### Run the test snapshots in unit tests | ||
|
||
- upload the test snapshots (`.zst` format is recommended) to the Digital Ocean space `forest-snapshots/rpc_test` | ||
- include the file names in `src/tool/subcommands/api_cmd/test_snapshots.txt` | ||
- run `cargo test --lib -- --test rpc_regression_tests --nocapture` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's note that a running instance of Forest and Lotus are required, the latter requiring some environmental variables set (refer to docker compose file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LesnyRumcajs please re-approve if the change look good, thanks!