feat(net): make Status and Hello configurable (#431)

* feat(net): make Status and Hello configurable

* set port
This commit is contained in:
Matthias Seitz
2022-12-14 11:39:09 +01:00
committed by GitHub
parent ac5efc0749
commit 12e7f0acbc
7 changed files with 199 additions and 41 deletions

View File

@ -87,6 +87,34 @@ async fn test_connect_with_boot_nodes() {
}
}
#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn test_connect_with_builder() {
reth_tracing::init_tracing();
let secret_key = SecretKey::new(&mut rand::thread_rng());
let mut discv4 = Discv4Config::builder();
discv4.add_boot_nodes(mainnet_nodes());
let client = Arc::new(TestApi::default());
let config = NetworkConfig::builder(Arc::clone(&client), secret_key).discovery(discv4).build();
let (handle, network, _, requests) = NetworkManager::new(config)
.await
.unwrap()
.into_builder()
.request_handler(client)
.split_with_handle();
let mut events = handle.event_listener();
tokio::task::spawn(async move {
tokio::join!(network, requests);
});
while let Some(ev) = events.next().await {
dbg!(ev);
}
}
#[tokio::test(flavor = "multi_thread")]
async fn test_incoming_node_id_blacklist() {
reth_tracing::init_tracing();
@ -200,7 +228,7 @@ async fn test_outgoing_connect_with_single_geth() {
let geth_socket = SocketAddr::new([127, 0, 0, 1].into(), geth_p2p_port);
let geth_endpoint = SocketAddr::new([127, 0, 0, 1].into(), geth.port()).to_string();
let provider = Provider::<Http>::try_from(format!("http://{}", geth_endpoint)).unwrap();
let provider = Provider::<Http>::try_from(format!("http://{geth_endpoint}")).unwrap();
// get the peer id we should be expecting
let geth_peer_id: PeerId =