mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: trim cmd args in parser (#3789)
This commit is contained in:
committed by
GitHub
parent
300b496686
commit
be656c239a
@ -526,6 +526,25 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transport_rpc_module_trim_config() {
|
||||
let args = CommandParser::<RpcServerArgs>::parse_from([
|
||||
"reth",
|
||||
"--http.api",
|
||||
" eth, admin, debug",
|
||||
"--http",
|
||||
"--ws",
|
||||
])
|
||||
.args;
|
||||
let config = args.transport_rpc_module_config();
|
||||
let expected = vec![RethRpcModule::Eth, RethRpcModule::Admin, RethRpcModule::Debug];
|
||||
assert_eq!(config.http().cloned().unwrap().into_selection(), expected);
|
||||
assert_eq!(
|
||||
config.ws().cloned().unwrap().into_selection(),
|
||||
RpcModuleSelection::standard_modules()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rpc_server_config() {
|
||||
let args = CommandParser::<RpcServerArgs>::parse_from([
|
||||
|
||||
@ -604,7 +604,7 @@ impl FromStr for RpcModuleSelection {
|
||||
type Err = ParseError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut modules = s.split(',').peekable();
|
||||
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),
|
||||
|
||||
Reference in New Issue
Block a user