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

Add http/ipc jsonrpc testing to harness #148

Merged
merged 3 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ through github via pull requests.
* Mark unfinished pull requests with the "Work in Progress" label.
* Before submitting a pr for review, you should run the following commands
locally and make sure they are passing, otherwise CI will raise an error.
* `cargo fmt` and `cargo clippy` for linting checks
* `cargo test --workspace` to run all tests
* `cargo fmt --all -- --check` and `cargo clippy --all -- --deny warnings` for linting checks
* `RUSTFLAGS='-D warnings' cargo test --workspace` to run all tests
* Run the `ethportal-peertest` harness against a locally running node. Instructions
can be found in [README](ethportal-peertest/README.md).
* Pull requests **should** always be reviewed by another member of the team
prior to being merged.
* Obvious exceptions include very small pull requests.
Expand Down
118 changes: 117 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ethportal-peertest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ edition = "2018"

[dependencies]
clap = "2.33.3"
hyper = { version = "0.14", features = ["full"] }
log = "0.4.14"
rocksdb = "0.16.0"
serde_json = "1.0.59"
structopt = "0.3"
thiserror = "1.0.29"
tokio = {version = "1.8.0", features = ["full"]}
tracing = "0.1.26"
tracing-subscriber = "0.2.18"
Expand Down
7 changes: 5 additions & 2 deletions ethportal-peertest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Run a portal network node that you want to test and pass node's Enr as a target
```sh
cd ethportal-peertest

RUST_LOG=debug cargo run -p ethportal-peertest -- --target_node enr:-IS4QBDHCSMoYoC5UziAwKSyTmMPrhMaEpaE52L8DDAkipqvZQe9fgLy2wVuuEJwO9l1KsYrRoFGCsNjylbd0CDNw60BgmlkgnY0gmlwhMCoXUSJc2VjcDI1NmsxoQJPAZUFErHK1DZYRTLjk3SCNgye9sS-MxoQI-gLiUdwc4N1ZHCCIyk
RUST_LOG=debug cargo run -p ethportal-peertest -- --target-node enr:-IS4QBDHCSMoYoC5UziAwKSyTmMPrhMaEpaE52L8DDAkipqvZQe9fgLy2wVuuEJwO9l1KsYrRoFGCsNjylbd0CDNw60BgmlkgnY0gmlwhMCoXUSJc2VjcDI1NmsxoQJPAZUFErHK1DZYRTLjk3SCNgye9sS-MxoQI-gLiUdwc4N1ZHCCIyk
```

## Transport selection
Running the test harness will by default test all jsonrpc endpoints over IPC to the target node. To make sure these pass, please make sure that the target node is running with `--web3-transport ipc`. To test jsonrpc over http, use the `--target-transport http` cli argument for the harness, and make sure the target node is running with `--web3-transport http`. Ideally, both transport methods are tested before PRs.

```
32 changes: 28 additions & 4 deletions ethportal-peertest/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::env;
use std::ffi::OsString;
use structopt::StructOpt;
use trin_core::cli::DEFAULT_WEB3_HTTP_PORT as DEFAULT_TARGET_HTTP_PORT;
use trin_core::cli::DEFAULT_WEB3_IPC_PATH as DEFAULT_TARGET_IPC_PATH;

const DEFAULT_LISTEN_PORT: &str = "9876";
const DEFAULT_WEB3_IPC_PATH: &str = "/tmp/json-rpc-peertest.ipc";
Expand All @@ -15,24 +17,46 @@ pub struct PeertestConfig {
#[structopt(
default_value(DEFAULT_LISTEN_PORT),
short = "p",
long = "listen_port",
long = "listen-port",
help = "The UDP port to listen on."
)]
pub listen_port: u16,

#[structopt(
default_value(DEFAULT_WEB3_IPC_PATH),
long = "web3_ipc_path",
long = "web3-ipc-path",
help = "path to json-rpc socket address over IPC"
)]
pub web3_ipc_path: String,

#[structopt(
short,
long = "target_node",
help = "Base64-encoded ENR's of the nodes under test"
long = "target-node",
help = "Base64-encoded ENR of the node under test"
)]
pub target_node: String,

#[structopt(
default_value = "ipc",
possible_values(&["http", "ipc"]),
long = "target-transport",
help = "Transport type of the node under test"
)]
pub target_transport: String,

#[structopt(
default_value = DEFAULT_TARGET_IPC_PATH,
long = "target-ipc-path",
help = "IPC path of target node under test"
)]
pub target_ipc_path: String,

#[structopt(
default_value = DEFAULT_TARGET_HTTP_PORT,
long = "target-http-port",
help = "HTTP port of target node under test"
)]
pub target_http_port: String,
}

impl PeertestConfig {
Expand Down
Loading