diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 2d50dc6c635..cec5ff621cd 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -2888,7 +2888,7 @@ pub fn serve( .map_err(warp_utils::reject::beacon_chain_error)?; let syncing_data = api_types::SyncingData { - is_syncing: network_globals.sync_state.read().is_syncing(), + is_syncing: !network_globals.sync_state.read().is_synced(), is_optimistic: Some(is_optimistic), el_offline: Some(el_offline), head_slot, diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 633baaf6f40..0733b60f7d5 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -23,7 +23,7 @@ use http_api::{ test_utils::{create_api_server, ApiServer}, BlockId, StateId, }; -use lighthouse_network::{Enr, EnrExt, PeerId}; +use lighthouse_network::{types::SyncState, Enr, EnrExt, PeerId}; use network::NetworkReceivers; use proto_array::ExecutionStatus; use sensitive_url::SensitiveUrl; @@ -62,6 +62,7 @@ const SKIPPED_SLOTS: &[u64] = &[ ]; struct ApiTester { + ctx: Arc>>, harness: Arc>>, chain: Arc>>, client: BeaconNodeHttpClient, @@ -253,7 +254,7 @@ impl ApiTester { let log = null_logger().unwrap(); let ApiServer { - ctx: _, + ctx, server, listening_socket, network_rx, @@ -284,6 +285,7 @@ impl ApiTester { ); Self { + ctx, harness: Arc::new(harness), chain, client, @@ -350,7 +352,7 @@ impl ApiTester { let log = null_logger().unwrap(); let ApiServer { - ctx: _, + ctx, server, listening_socket, network_rx, @@ -371,6 +373,7 @@ impl ApiTester { ); Self { + ctx, harness, chain, client, @@ -2168,6 +2171,37 @@ impl ApiTester { self } + pub async fn test_get_node_syncing_stalled(self) -> Self { + // Set sync status to stalled. + *self + .ctx + .network_globals + .as_ref() + .unwrap() + .sync_state + .write() = SyncState::Stalled; + + let is_syncing = self + .client + .get_node_syncing() + .await + .unwrap() + .data + .is_syncing; + assert_eq!(is_syncing, true); + + // Reset sync state. + *self + .ctx + .network_globals + .as_ref() + .unwrap() + .sync_state + .write() = SyncState::Synced; + + self + } + pub async fn test_get_node_identity(self) -> Self { let result = self.client.get_node_identity().await.unwrap().data; @@ -6123,6 +6157,8 @@ async fn node_get() { .await .test_get_node_syncing() .await + .test_get_node_syncing_stalled() + .await .test_get_node_identity() .await .test_get_node_health()