Skip to content

Commit

Permalink
test: Fuzz testing RPC (#2740)
Browse files Browse the repository at this point in the history
test: Fuzz testing RPC #2422 

Fuzzer to test RPC connections, by sending:

- [x] Invalid methods
- [ ] Correct method with invalid formatted data
- [x] Correct method with validly formatted random data

How to run fuzzing
-------------------

```bach
$ cd chain/jsonrpc
$ cargo install cargo-fuzz  # (if not installed)
$ cargo fuzz run fuzz_target_1
```

**Note** there is some bug in Rust, already fixed but still not included in nightly release, somehow related to MacOS Catalina, so fuzzing is possible only in Linux (definitely) and probably on Windows (haven't check). 

References:
rust-lang/rust#63047 (comment)
servo/core-foundation-rs#357

Test plan
---------

1. test query methods with valid random data and ensure RPC response status is 200 and response contains `error` key instead of `result`.
2. test for valid methods with invalid format of data. Should return 200 and `error` in response.
3. test for invalid methods
  • Loading branch information
khorolets committed Jun 10, 2020
1 parent 784368d commit 08e1443
Show file tree
Hide file tree
Showing 11 changed files with 8,317 additions and 1,145 deletions.
2,663 changes: 1,520 additions & 1,143 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ members = [
"chain/network",
"chain/jsonrpc",
"chain/jsonrpc/client",
"chain/jsonrpc/test-utils",
"test-utils/testlib",
"test-utils/loadtester",
"test-utils/state-viewer",
Expand Down
4 changes: 2 additions & 2 deletions chain/jsonrpc/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ macro_rules! jsonrpc_client {
) => (
$(#[$struct_attr])*
pub struct $struct_name {
server_addr: String,
client: Client,
pub server_addr: String,
pub client: Client,
}

impl $struct_name {
Expand Down
4 changes: 4 additions & 0 deletions chain/jsonrpc/fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

target
corpus
artifacts

0 comments on commit 08e1443

Please sign in to comment.