fix(net): syncing should be true at startup (#2395)

This commit is contained in:
Matthias Seitz
2023-04-25 17:09:37 +02:00
committed by GitHub
parent 9ee601a7a1
commit c132c6681a
2 changed files with 13 additions and 1 deletions

View File

@ -57,7 +57,7 @@ impl NetworkHandle {
peers,
network_mode,
bandwidth_meter,
is_syncing: Arc::new(Default::default()),
is_syncing: Arc::new(AtomicBool::new(true)),
chain_id,
};
Self { inner: Arc::new(inner) }

View File

@ -3,6 +3,7 @@ use reth_network::{
error::{NetworkError, ServiceKind},
Discovery, NetworkConfigBuilder, NetworkManager,
};
use reth_network_api::NetworkInfo;
use reth_provider::test_utils::NoopProvider;
use secp256k1::SecretKey;
use std::{
@ -19,6 +20,17 @@ fn is_addr_in_use_kind(err: NetworkError, kind: ServiceKind) -> bool {
}
}
#[tokio::test(flavor = "multi_thread")]
async fn test_is_default_syncing() {
let secret_key = SecretKey::new(&mut rand::thread_rng());
let config = NetworkConfigBuilder::new(secret_key)
.disable_discovery()
.listener_port(0)
.build(NoopProvider::default());
let network = NetworkManager::new(config).await.unwrap();
assert!(network.handle().is_syncing());
}
#[tokio::test(flavor = "multi_thread")]
async fn test_listener_addr_in_use() {
let secret_key = SecretKey::new(&mut rand::thread_rng());