Skip to content

Commit 95e679a

Browse files
committed
make gen-doc
1 parent 4d38fff commit 95e679a

File tree

6 files changed

+82
-14
lines changed

6 files changed

+82
-14
lines changed

cmd/loadtest/loadtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ func initializeAccountPool(ctx context.Context, c *ethclient.Client, privateKey
340340
if len(privateKeys) == 0 {
341341
const errMsg = "no private keys found in sending accounts file"
342342
log.Error().Str("sendingAccountsFile", sendingAccountsFile).Msg(errMsg)
343-
return fmt.Errorf(errMsg)
343+
return errors.New(errMsg)
344344
}
345345

346346
if len(privateKeys) > 1 && *inputLoadTestParams.StartNonce > 0 {

cmd/rpcfuzz/rpcfuzz.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ func runRpcFuzz(ctx context.Context) error {
261261

262262
execution := CallRPCAndValidate(ctx, rpcClient, wrappedHTTPClient, t)
263263
if shouldOutput(execution) {
264-
outputStreamer.StreamTestExecution(execution)
264+
iErr := outputStreamer.StreamTestExecution(execution)
265+
if iErr != nil {
266+
log.Error().Err(iErr).Msg("Unable to stream test execution")
267+
}
265268
}
266269

267270
summary := createSummaryFromExecution(t, execution)
@@ -276,12 +279,18 @@ func runRpcFuzz(ctx context.Context) error {
276279
// Periodic summary output
277280
if *summaryInterval > 0 && len(summaries)%(*summaryInterval) == 0 {
278281
overallSummary := calculateProgressSummary(summaries)
279-
outputStreamer.StreamSummary(overallSummary)
282+
iErr := outputStreamer.StreamSummary(overallSummary)
283+
if iErr != nil {
284+
log.Error().Err(iErr).Msg("Unable to stream summary")
285+
}
280286
}
281287
}
282288

283289
// Final summary
284-
outputStreamer.StreamFinalSummary(summaries)
290+
err = outputStreamer.StreamFinalSummary(summaries)
291+
if err != nil {
292+
log.Error().Err(err).Msg("Unable to stream final summary")
293+
}
285294

286295
return nil
287296
}
@@ -449,7 +458,10 @@ func CallRPCWithFuzzAndValidate(ctx context.Context, rpcClient *rpc.Client, curr
449458
}
450459

451460
if shouldOutput(execution) {
452-
outputStreamer.StreamTestExecution(execution)
461+
iErr := outputStreamer.StreamTestExecution(execution)
462+
if iErr != nil {
463+
log.Error().Err(iErr).Msg("Unable to stream test execution")
464+
}
453465
}
454466
}
455467

cmd/rpcfuzz/streamer/csv.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package streamer
33
import (
44
"encoding/csv"
55
"encoding/json"
6+
"fmt"
67
"io"
78
"strconv"
89
)
@@ -28,7 +29,10 @@ func (c *CSVStreamer) StreamTestExecution(exec TestExecution) error {
2829
}
2930

3031
if !c.headerWritten {
31-
c.csvWriter.Write([]string{"test_name", "method", "args", "result", "status", "duration_ms", "timestamp", "error"})
32+
err := c.csvWriter.Write([]string{"test_name", "method", "args", "result", "status", "duration_ms", "timestamp", "error"})
33+
if err != nil {
34+
return fmt.Errorf("failed to write CSV header: %w", err)
35+
}
3236
c.headerWritten = true
3337
}
3438

doc/polycli_rpcfuzz.md

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,58 @@ Once this has been completed this will be the address of the contract: `0x6fda56
9393
$ docker run -v $PWD/contracts:/contracts ethereum/solc:stable --storage-layout /contracts/tokens/ERC20/ERC20.sol
9494
```
9595

96+
## Running RPC Fuzz Tests
97+
98+
After setting up your RPC endpoint and funding an account, you can run the RPC fuzz tests using various output formats. The tool supports streaming output that follows Unix philosophy - results are sent to stdout and you control data persistence through shell redirection.
99+
100+
### Output Format Examples
101+
102+
All commands use the same core parameters but produce different output formats:
103+
104+
#### Compact Format (Default)
105+
Real-time colored console output with pass/fail indicators:
106+
```bash
107+
polycli rpcfuzz --rpc-url http://localhost:8545 --private-key <YOUR_PRIVATE_KEY> --namespaces eth,web3,net --compact > results.txt
108+
```
109+
110+
#### CSV Format
111+
Structured CSV with headers for data analysis:
112+
```bash
113+
polycli rpcfuzz --rpc-url http://localhost:8545 --private-key <YOUR_PRIVATE_KEY> --namespaces eth,web3,net --csv > results.csv
114+
```
115+
116+
#### JSON Format
117+
Streaming JSON with detailed test execution data:
118+
```bash
119+
polycli rpcfuzz --rpc-url http://localhost:8545 --private-key <YOUR_PRIVATE_KEY> --namespaces eth,web3,net --json > results.json
120+
```
121+
122+
#### HTML Format
123+
Complete styled HTML document for browser viewing:
124+
```bash
125+
polycli rpcfuzz --rpc-url http://localhost:8545 --private-key <YOUR_PRIVATE_KEY> --namespaces eth,web3,net --html > results.html
126+
```
127+
128+
#### Markdown Format
129+
Formatted Markdown table with emoji indicators:
130+
```bash
131+
polycli rpcfuzz --rpc-url http://localhost:8545 --private-key <YOUR_PRIVATE_KEY> --namespaces eth,web3,net --md > results.md
132+
```
133+
134+
### Command Options
135+
136+
- `--rpc-url`: The JSON RPC endpoint URL
137+
- `--private-key`: Private key for account with funds for testing
138+
- `--namespaces`: Comma-separated list of RPC method namespaces to test (e.g., `eth,web3,net`)
139+
- Output format flags: `--compact`, `--csv`, `--json`, `--html`, `--md` (mutually exclusive)
140+
141+
### Example with Error Suppression
142+
143+
To capture only test results without debug output:
144+
```bash
145+
polycli rpcfuzz --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> --namespaces eth,web3,net --json 2>/dev/null > clean_results.json
146+
```
147+
96148
### Links
97149

98150
- https://ethereum.github.io/execution-apis/api-documentation/
@@ -103,19 +155,22 @@ $ docker run -v $PWD/contracts:/contracts ethereum/solc:stable --storage-layout
103155
## Flags
104156

105157
```bash
158+
--compact Stream output in compact format (default)
106159
--contract-address string The address of a contract that can be used for testing. If not specified, a contract will be deployed automatically.
107-
--csv Flag to indicate that output will be exported as a CSV.
108-
--export-path string The directory export path of the output of the tests. Must pair this with either --json, --csv, --md, or --html
160+
--csv Stream output in CSV format
109161
--fuzz Flag to indicate whether to fuzz input or not.
110162
--fuzzn int Number of times to run the fuzzer per test. (default 100)
111163
-h, --help help for rpcfuzz
112-
--html Flag to indicate that output will be exported as a HTML.
113-
--json Flag to indicate that output will be exported as a JSON.
114-
--md Flag to indicate that output will be exported as a Markdown.
164+
--html Stream output in HTML format
165+
--json Stream output in JSON format
166+
--md Stream output in Markdown format
115167
--namespaces string Comma separated list of rpc namespaces to test (default "eth,web3,net,debug,raw")
168+
--output string What to output: all, failures, summary (default "all")
116169
--private-key string The hex encoded private key that we'll use to sending transactions (default "42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa")
170+
--quiet Only show final summary
117171
-r, --rpc-url string The RPC endpoint url (default "http://localhost:8545")
118172
--seed int A seed for generating random values within the fuzzer (default 123456)
173+
--summary-interval int Print summary every N tests (0=disabled)
119174
```
120175
121176
The command also inherits flags from parent commands.

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ require (
1414
github.com/gizak/termui/v3 v3.1.1-0.20231111080052-b3569a6cd52d
1515
github.com/google/gofuzz v1.2.0
1616
github.com/hashicorp/golang-lru v1.0.2
17-
github.com/jedib0t/go-pretty/v6 v6.6.8
1817
github.com/libp2p/go-libp2p v0.36.5
1918
github.com/manifoldco/promptui v0.9.0
2019
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,6 @@ github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
306306
github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk=
307307
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
308308
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
309-
github.com/jedib0t/go-pretty/v6 v6.6.8 h1:JnnzQeRz2bACBobIaa/r+nqjvws4yEhcmaZ4n1QzsEc=
310-
github.com/jedib0t/go-pretty/v6 v6.6.8/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU=
311309
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
312310
github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U=
313311
github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=

0 commit comments

Comments
 (0)