mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 00:58:11 -05:00
Feat/enable non namespaces (#5391)
This commit is contained in:
@@ -502,6 +502,7 @@ impl TypedValueParser for RpcModuleSelectionValueParser {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use clap::Parser;
|
||||
use reth_rpc_builder::RpcModuleSelection::Selection;
|
||||
use std::net::SocketAddrV4;
|
||||
|
||||
/// A helper type to parse Args more easily
|
||||
@@ -538,6 +539,14 @@ mod tests {
|
||||
assert_eq!(apis, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rpc_server_args_parser_none() {
|
||||
let args = CommandParser::<RpcServerArgs>::parse_from(["reth", "--http.api", "none"]).args;
|
||||
let apis = args.http_api.unwrap();
|
||||
let expected = Selection(vec![]);
|
||||
assert_eq!(apis, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transport_rpc_module_config() {
|
||||
let args = CommandParser::<RpcServerArgs>::parse_from([
|
||||
|
||||
@@ -135,7 +135,10 @@
|
||||
#![warn(missing_debug_implementations, missing_docs, unreachable_pub, rustdoc::all)]
|
||||
#![deny(unused_must_use, rust_2018_idioms)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
use crate::{auth::AuthRpcModule, error::WsHttpSamePortError, metrics::RpcServerMetrics};
|
||||
use crate::{
|
||||
auth::AuthRpcModule, error::WsHttpSamePortError, metrics::RpcServerMetrics,
|
||||
RpcModuleSelection::Selection,
|
||||
};
|
||||
use constants::*;
|
||||
use error::{RpcError, ServerKind};
|
||||
use hyper::{header::AUTHORIZATION, HeaderMap};
|
||||
@@ -679,10 +682,14 @@ impl FromStr for RpcModuleSelection {
|
||||
type Err = ParseError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
if s.is_empty() {
|
||||
return Ok(Selection(vec![]))
|
||||
}
|
||||
let mut modules = s.split(',').map(str::trim).peekable();
|
||||
let first = modules.peek().copied().ok_or(ParseError::VariantNotFound)?;
|
||||
match first {
|
||||
"all" | "All" => Ok(RpcModuleSelection::All),
|
||||
"none" | "None" => Ok(Selection(vec![])),
|
||||
_ => RpcModuleSelection::try_from_selection(modules),
|
||||
}
|
||||
}
|
||||
@@ -2035,6 +2042,12 @@ mod tests {
|
||||
assert_eq!(selection, RpcModuleSelection::All);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_rpc_module_selection_none() {
|
||||
let selection = "none".parse::<RpcModuleSelection>().unwrap();
|
||||
assert_eq!(selection, Selection(vec![]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_rpc_unique_module_selection() {
|
||||
let selection = "eth,admin,eth,net".parse::<RpcModuleSelection>().unwrap();
|
||||
@@ -2122,4 +2135,18 @@ mod tests {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_configure_transport_config_none() {
|
||||
let config = TransportRpcModuleConfig::default().with_http(Vec::<RethRpcModule>::new());
|
||||
assert_eq!(
|
||||
config,
|
||||
TransportRpcModuleConfig {
|
||||
http: Some(RpcModuleSelection::Selection(vec![])),
|
||||
ws: None,
|
||||
ipc: None,
|
||||
config: None,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user