mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
test(cli): add chain args test (#1488)
This commit is contained in:
@ -167,10 +167,9 @@ impl RpcServerArgs {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::net::SocketAddrV4;
|
||||
|
||||
use super::*;
|
||||
use clap::Parser;
|
||||
use std::net::SocketAddrV4;
|
||||
|
||||
/// A helper type to parse Args more easily
|
||||
#[derive(Parser)]
|
||||
|
||||
@ -173,3 +173,17 @@ impl ImportCommand {
|
||||
confy::load_path::<Config>(&self.config).wrap_err("Could not load config")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn parse_common_import_command_chain_args() {
|
||||
for chain in ["mainnet", "sepolia", "goerli"] {
|
||||
let args: ImportCommand =
|
||||
ImportCommand::parse_from(["reth", "--chain", chain, "--path", "."]);
|
||||
assert_eq!(args.chain.chain, chain.parse().unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +36,6 @@ use reth_network::{
|
||||
use reth_network_api::NetworkInfo;
|
||||
use reth_primitives::{BlockNumber, ChainSpec, Head, H256};
|
||||
use reth_provider::{BlockProvider, HeaderProvider, ShareableDatabase};
|
||||
|
||||
use reth_staged_sync::{
|
||||
utils::{
|
||||
chainspec::genesis_value_parser,
|
||||
@ -500,3 +499,16 @@ pub async fn handle_events(mut events: impl Stream<Item = NodeEvent> + Unpin) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn parse_common_node_command_chain_args() {
|
||||
for chain in ["mainnet", "sepolia", "goerli"] {
|
||||
let args: Command = Command::parse_from(["reth", "--chain", chain]);
|
||||
assert_eq!(args.chain.chain, chain.parse().unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,3 +29,16 @@ pub fn genesis_value_parser(s: &str) -> Result<ChainSpec, eyre::Error> {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn parse_chain_spec() {
|
||||
for chain in ["mainnet", "sepolia", "goerli"] {
|
||||
chain_spec_value_parser(chain).unwrap();
|
||||
genesis_value_parser(chain).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user