mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-04 12:05:12 -05:00
64 lines
1.9 KiB
Rust
64 lines
1.9 KiB
Rust
//! Node builder setup tests.
|
|
|
|
use reth_db::test_utils::create_test_rw_db;
|
|
use reth_node_builder::{FullNodeComponents, NodeBuilder, NodeConfig};
|
|
use reth_node_ethereum::{
|
|
launch::EthNodeLauncher,
|
|
node::{EthereumAddOns, EthereumNode},
|
|
};
|
|
use reth_tasks::TaskManager;
|
|
|
|
#[test]
|
|
fn test_basic_setup() {
|
|
// parse CLI -> config
|
|
let config = NodeConfig::test();
|
|
let db = create_test_rw_db();
|
|
let msg = "On components".to_string();
|
|
let _builder = NodeBuilder::new(config)
|
|
.with_database(db)
|
|
.with_types::<EthereumNode>()
|
|
.with_components(EthereumNode::components())
|
|
.with_add_ons::<EthereumAddOns>()
|
|
.on_component_initialized(move |ctx| {
|
|
let _provider = ctx.provider();
|
|
println!("{msg}");
|
|
Ok(())
|
|
})
|
|
.on_node_started(|_full_node| Ok(()))
|
|
.on_rpc_started(|_ctx, handles| {
|
|
let _client = handles.rpc.http_client();
|
|
Ok(())
|
|
})
|
|
.extend_rpc_modules(|ctx| {
|
|
let _ = ctx.config();
|
|
let _ = ctx.node().provider();
|
|
|
|
Ok(())
|
|
})
|
|
.check_launch();
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_eth_launcher() {
|
|
let tasks = TaskManager::current();
|
|
let config = NodeConfig::test();
|
|
let db = create_test_rw_db();
|
|
let _builder = NodeBuilder::new(config)
|
|
.with_database(db)
|
|
.with_types::<EthereumNode>()
|
|
.with_components(EthereumNode::components())
|
|
.with_add_ons::<EthereumAddOns>()
|
|
.launch_with_fn(|builder| {
|
|
let launcher = EthNodeLauncher::new(tasks.executor(), builder.config.datadir());
|
|
builder.launch_with(launcher)
|
|
});
|
|
}
|
|
|
|
#[test]
|
|
fn test_node_setup() {
|
|
let config = NodeConfig::test();
|
|
let db = create_test_rw_db();
|
|
let _builder =
|
|
NodeBuilder::new(config).with_database(db).node(EthereumNode::default()).check_launch();
|
|
}
|