Collection of JSON-RPC black-box testing tools for Ethereum node implementations.
- Installation
- Integration Testing
- Performance Testing
- Standalone Tools
- Development
- Legacy Python Tools
- Go >= 1.24
git clone https://github.com/erigontech/rpc-tests.git
cd rpc-tests
make
Check out the dedicated guide in Integration Tests.
Check out the dedicated guide in Performance Tests.
The rpc_int binary includes several standalone subcommands for targeted testing and diagnostics. Each subcommand has its own --help flag.
Query block numbers for latest, safe, and finalized tags via WebSocket every 2 seconds.
./build/bin/rpc_int block-by-number --url ws://127.0.0.1:8545| Flag | Default | Description |
|---|---|---|
--url |
ws://127.0.0.1:8545 |
WebSocket URL of the Ethereum node |
Search backward from the latest block for N empty blocks (no transactions).
./build/bin/rpc_int empty-blocks --url http://localhost:8545 --count 10| Flag | Default | Description |
|---|---|---|
--url |
http://localhost:8545 |
HTTP URL of the Ethereum node |
--count |
10 |
Number of empty blocks to find |
--ignore-withdrawals |
false |
Ignore withdrawals when determining if a block is empty |
--compare-state-root |
false |
Compare state root with parent block |
Create an ERC20 Transfer filter and poll for changes/logs via WebSocket.
./build/bin/rpc_int filter-changes --url ws://127.0.0.1:8545| Flag | Default | Description |
|---|---|---|
--url |
ws://127.0.0.1:8545 |
WebSocket URL of the Ethereum node |
Monitor the latest block and validate eth_getLogs results against the block's receiptsRoot.
./build/bin/rpc_int latest-block-logs --url http://localhost:8545| Flag | Default | Description |
|---|---|---|
--url |
http://127.0.0.1:8545 |
HTTP URL of the Ethereum node |
--interval |
0.1 |
Sleep interval between queries in seconds |
Subscribe to newHeads and USDT Transfer logs via WebSocket.
./build/bin/rpc_int subscriptions --url ws://127.0.0.1:8545| Flag | Default | Description |
|---|---|---|
--url |
ws://127.0.0.1:8545 |
WebSocket URL of the Ethereum node |
Execute GraphQL queries or run GraphQL test suites downloaded from GitHub.
# Single query
./build/bin/rpc_int graphql --http-url http://127.0.0.1:8545/graphql --query '{block{number}}'
# Run test suite from GitHub
./build/bin/rpc_int graphql --http-url http://127.0.0.1:8545/graphql --tests-url https://api.github.com/repos/.../git/trees/...| Flag | Default | Description |
|---|---|---|
--http-url |
http://127.0.0.1:8545/graphql |
GraphQL endpoint URL |
--query |
GraphQL query string (mutually exclusive with --tests-url) |
|
--tests-url |
GitHub tree URL with test files (mutually exclusive with --query) |
|
--stop-at-first-error |
false |
Stop at first test error |
--test-number |
-1 |
Run only the test at this index (0-based) |
Replay JSON-RPC Engine API requests extracted from log files.
./build/bin/rpc_int replay-request --path /path/to/logs --url http://localhost:8551 --jwt /path/to/jwt.hex| Flag | Default | Description |
|---|---|---|
--url |
http://localhost:8551 |
HTTP URL of Engine API endpoint |
--method |
engine_newPayloadV3 |
JSON-RPC method to replay |
--index |
1 |
Ordinal index of method occurrence (-1 for all) |
--jwt |
$HOME/prysm/jwt.hex |
Path to JWT secret file |
--path |
platform-specific | Path to Engine API log directory |
--pretend |
false |
Dry run: do not send any HTTP request |
-v, --verbose |
false |
Print verbose output |
Scan blocks and compare trace responses between two servers.
./build/bin/rpc_int replay-tx --start 1000000:0 --method 0| Flag | Default | Description |
|---|---|---|
--start |
0:0 |
Starting point as block:tx |
-c, --continue |
false |
Continue scanning, don't stop at first diff |
-n, --number |
0 |
Max number of failed txs before stopping |
-m, --method |
0 |
0: trace_replayTransaction, 1: debug_traceTransaction |
Verify receipts root integrity by computing the MPT root from actual receipts and comparing against the block header.
# Scan a specific block range
./build/bin/rpc_int scan-block-receipts --url http://localhost:8545 --start-block 100 --end-block 200
# Continuously monitor latest blocks
./build/bin/rpc_int scan-block-receipts --url http://localhost:8545| Flag | Default | Description |
|---|---|---|
--url |
http://127.0.0.1:8545 |
HTTP URL of the Ethereum node |
--start-block |
-1 |
Starting block number (inclusive) |
--end-block |
-1 |
Ending block number (inclusive) |
--beyond-latest |
false |
Scan next-after-latest blocks |
--stop-at-reorg |
false |
Stop at first chain reorg |
--interval |
0.1 |
Sleep interval between queries in seconds |
make testmake lintThe previous Python-based implementation is still available under src/rpctests/.
Python setup and tools
- Python >= 3.10
Vegeta>= 12.8.4 (for performance testing only)json-diff(via npm, for integration testing)python3-jsonpatch>= 1.32 (for integration testing)
Create your local virtual environment:
python3 -m venv .venvActivate it:
source .venv/bin/activate # Linux/macOS.\.venv\Scripts\activate # WindowsAfter you've updated to the latest code with git pull, update the dependencies:
pip3 install -r requirements.txtcd src| Tool | Command |
|---|---|
| Get Latest/Safe/Finalized Blocks | python3 -m rpctests.block_by_number |
| Find Empty Blocks | python3 -m rpctests.empty_blocks |
| Query Filter Changes | python3 -m rpctests.filter_changes |
| Get Latest Block Logs | python3 -m rpctests.latest_block_logs |
| GraphQL | python3 -m rpctests.graphql |
| Replay Request | python3 -m rpctests.replay_request |
| Replay Tx | python3 -m rpctests.replay_tx |
| Scan Block Receipts | python3 -m rpctests.scan_block_receipts |
| Send Raw Transaction Sync | python3 -m rpctests.send_raw_transaction_sync |
| Subscribe and Call Fee History | python3 -m rpctests.subscribe_and_call_fee_history |
| Subscribe and Check Receipts | python3 -m rpctests.subscribe_and_check_receipts |
| Subscriptions | python3 -m rpctests.subscriptions |
pytest