mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 12:54:27 +00:00
Return syncing on HTTP when sync is stalled (#6129)
* Return syncing even when sync is stalled * Add test
This commit is contained in:
@@ -2888,7 +2888,7 @@ pub fn serve<T: BeaconChainTypes>(
|
|||||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||||
|
|
||||||
let syncing_data = api_types::SyncingData {
|
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),
|
is_optimistic: Some(is_optimistic),
|
||||||
el_offline: Some(el_offline),
|
el_offline: Some(el_offline),
|
||||||
head_slot,
|
head_slot,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use http_api::{
|
|||||||
test_utils::{create_api_server, ApiServer},
|
test_utils::{create_api_server, ApiServer},
|
||||||
BlockId, StateId,
|
BlockId, StateId,
|
||||||
};
|
};
|
||||||
use lighthouse_network::{Enr, EnrExt, PeerId};
|
use lighthouse_network::{types::SyncState, Enr, EnrExt, PeerId};
|
||||||
use network::NetworkReceivers;
|
use network::NetworkReceivers;
|
||||||
use proto_array::ExecutionStatus;
|
use proto_array::ExecutionStatus;
|
||||||
use sensitive_url::SensitiveUrl;
|
use sensitive_url::SensitiveUrl;
|
||||||
@@ -62,6 +62,7 @@ const SKIPPED_SLOTS: &[u64] = &[
|
|||||||
];
|
];
|
||||||
|
|
||||||
struct ApiTester {
|
struct ApiTester {
|
||||||
|
ctx: Arc<http_api::Context<EphemeralHarnessType<E>>>,
|
||||||
harness: Arc<BeaconChainHarness<EphemeralHarnessType<E>>>,
|
harness: Arc<BeaconChainHarness<EphemeralHarnessType<E>>>,
|
||||||
chain: Arc<BeaconChain<EphemeralHarnessType<E>>>,
|
chain: Arc<BeaconChain<EphemeralHarnessType<E>>>,
|
||||||
client: BeaconNodeHttpClient,
|
client: BeaconNodeHttpClient,
|
||||||
@@ -253,7 +254,7 @@ impl ApiTester {
|
|||||||
let log = null_logger().unwrap();
|
let log = null_logger().unwrap();
|
||||||
|
|
||||||
let ApiServer {
|
let ApiServer {
|
||||||
ctx: _,
|
ctx,
|
||||||
server,
|
server,
|
||||||
listening_socket,
|
listening_socket,
|
||||||
network_rx,
|
network_rx,
|
||||||
@@ -284,6 +285,7 @@ impl ApiTester {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
ctx,
|
||||||
harness: Arc::new(harness),
|
harness: Arc::new(harness),
|
||||||
chain,
|
chain,
|
||||||
client,
|
client,
|
||||||
@@ -350,7 +352,7 @@ impl ApiTester {
|
|||||||
let log = null_logger().unwrap();
|
let log = null_logger().unwrap();
|
||||||
|
|
||||||
let ApiServer {
|
let ApiServer {
|
||||||
ctx: _,
|
ctx,
|
||||||
server,
|
server,
|
||||||
listening_socket,
|
listening_socket,
|
||||||
network_rx,
|
network_rx,
|
||||||
@@ -371,6 +373,7 @@ impl ApiTester {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
ctx,
|
||||||
harness,
|
harness,
|
||||||
chain,
|
chain,
|
||||||
client,
|
client,
|
||||||
@@ -2168,6 +2171,37 @@ impl ApiTester {
|
|||||||
self
|
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 {
|
pub async fn test_get_node_identity(self) -> Self {
|
||||||
let result = self.client.get_node_identity().await.unwrap().data;
|
let result = self.client.get_node_identity().await.unwrap().data;
|
||||||
|
|
||||||
@@ -6123,6 +6157,8 @@ async fn node_get() {
|
|||||||
.await
|
.await
|
||||||
.test_get_node_syncing()
|
.test_get_node_syncing()
|
||||||
.await
|
.await
|
||||||
|
.test_get_node_syncing_stalled()
|
||||||
|
.await
|
||||||
.test_get_node_identity()
|
.test_get_node_identity()
|
||||||
.await
|
.await
|
||||||
.test_get_node_health()
|
.test_get_node_health()
|
||||||
|
|||||||
Reference in New Issue
Block a user