mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Merge branch 'remove-into-gossip-verified-block' of https://github.com/realbigsean/lighthouse into merge-unstable-deneb-june-6th
This commit is contained in:
1270
beacon_node/http_api/tests/broadcast_validation_tests.rs
Normal file
1270
beacon_node/http_api/tests/broadcast_validation_tests.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
#![cfg(not(debug_assertions))] // Tests are too slow in debug.
|
||||
|
||||
pub mod broadcast_validation_tests;
|
||||
pub mod fork_tests;
|
||||
pub mod interactive_tests;
|
||||
pub mod status_tests;
|
||||
|
||||
@@ -3,6 +3,7 @@ use beacon_chain::{
|
||||
test_utils::{AttestationStrategy, BlockStrategy, SyncCommitteeStrategy},
|
||||
BlockError,
|
||||
};
|
||||
use eth2::StatusCode;
|
||||
use execution_layer::{PayloadStatusV1, PayloadStatusV1Status};
|
||||
use http_api::test_utils::InteractiveTester;
|
||||
use types::{EthSpec, ExecPayload, ForkName, MinimalEthSpec, Slot};
|
||||
@@ -149,3 +150,82 @@ async fn el_error_on_new_payload() {
|
||||
assert_eq!(api_response.is_optimistic, Some(false));
|
||||
assert_eq!(api_response.is_syncing, false);
|
||||
}
|
||||
|
||||
/// Check `node health` endpoint when the EL is offline.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn node_health_el_offline() {
|
||||
let num_blocks = E::slots_per_epoch() / 2;
|
||||
let num_validators = E::slots_per_epoch();
|
||||
let tester = post_merge_tester(num_blocks, num_validators).await;
|
||||
let harness = &tester.harness;
|
||||
let mock_el = harness.mock_execution_layer.as_ref().unwrap();
|
||||
|
||||
// EL offline
|
||||
mock_el.server.set_syncing_response(Err("offline".into()));
|
||||
mock_el.el.upcheck().await;
|
||||
|
||||
let status = tester.client.get_node_health().await;
|
||||
match status {
|
||||
Ok(_) => {
|
||||
panic!("should return 503 error status code");
|
||||
}
|
||||
Err(e) => {
|
||||
assert_eq!(e.status().unwrap(), 503);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Check `node health` endpoint when the EL is online and synced.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn node_health_el_online_and_synced() {
|
||||
let num_blocks = E::slots_per_epoch() / 2;
|
||||
let num_validators = E::slots_per_epoch();
|
||||
let tester = post_merge_tester(num_blocks, num_validators).await;
|
||||
let harness = &tester.harness;
|
||||
let mock_el = harness.mock_execution_layer.as_ref().unwrap();
|
||||
|
||||
// EL synced
|
||||
mock_el.server.set_syncing_response(Ok(false));
|
||||
mock_el.el.upcheck().await;
|
||||
|
||||
let status = tester.client.get_node_health().await;
|
||||
match status {
|
||||
Ok(response) => {
|
||||
assert_eq!(response, StatusCode::OK);
|
||||
}
|
||||
Err(_) => {
|
||||
panic!("should return 200 status code");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Check `node health` endpoint when the EL is online but not synced.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn node_health_el_online_and_not_synced() {
|
||||
let num_blocks = E::slots_per_epoch() / 2;
|
||||
let num_validators = E::slots_per_epoch();
|
||||
let tester = post_merge_tester(num_blocks, num_validators).await;
|
||||
let harness = &tester.harness;
|
||||
let mock_el = harness.mock_execution_layer.as_ref().unwrap();
|
||||
|
||||
// EL not synced
|
||||
harness.advance_slot();
|
||||
mock_el.server.all_payloads_syncing(true);
|
||||
harness
|
||||
.extend_chain(
|
||||
1,
|
||||
BlockStrategy::OnCanonicalHead,
|
||||
AttestationStrategy::AllValidators,
|
||||
)
|
||||
.await;
|
||||
|
||||
let status = tester.client.get_node_health().await;
|
||||
match status {
|
||||
Ok(response) => {
|
||||
assert_eq!(response, StatusCode::PARTIAL_CONTENT);
|
||||
}
|
||||
Err(_) => {
|
||||
panic!("should return 206 status code");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use eth2::{
|
||||
mixin::{RequestAccept, ResponseForkName, ResponseOptional},
|
||||
reqwest::RequestBuilder,
|
||||
types::{BlockId as CoreBlockId, ForkChoiceNode, StateId as CoreStateId, *},
|
||||
BeaconNodeHttpClient, Error, StatusCode, Timeouts,
|
||||
BeaconNodeHttpClient, Error, Timeouts,
|
||||
};
|
||||
use execution_layer::test_utils::TestingBuilder;
|
||||
use execution_layer::test_utils::DEFAULT_BUILDER_THRESHOLD_WEI;
|
||||
@@ -160,7 +160,7 @@ impl ApiTester {
|
||||
|
||||
// `make_block` adds random graffiti, so this will produce an alternate block
|
||||
let (reorg_block, _reorg_state) = harness
|
||||
.make_block(head.beacon_state.clone(), harness.chain.slot().unwrap())
|
||||
.make_block(head.beacon_state.clone(), harness.chain.slot().unwrap() + 1)
|
||||
.await;
|
||||
let reorg_block = SignedBlockContents::from(reorg_block);
|
||||
|
||||
@@ -1252,18 +1252,23 @@ impl ApiTester {
|
||||
}
|
||||
|
||||
pub async fn test_post_beacon_blocks_invalid(mut self) -> Self {
|
||||
let mut next_block = self.next_block.clone().deconstruct().0;
|
||||
*next_block.message_mut().proposer_index_mut() += 1;
|
||||
|
||||
assert!(self
|
||||
.client
|
||||
.post_beacon_blocks(&SignedBlockContents::from(next_block))
|
||||
let block = self
|
||||
.harness
|
||||
.make_block_with_modifier(
|
||||
self.harness.get_current_state(),
|
||||
self.harness.get_current_slot(),
|
||||
|b| {
|
||||
*b.state_root_mut() = Hash256::zero();
|
||||
},
|
||||
)
|
||||
.await
|
||||
.is_err());
|
||||
.0;
|
||||
|
||||
assert!(self.client.post_beacon_blocks(&SignedBlockContents::from(block)).await.is_err());
|
||||
|
||||
assert!(
|
||||
self.network_rx.network_recv.recv().await.is_some(),
|
||||
"invalid blocks should be sent to network"
|
||||
"gossip valid blocks should be sent to network"
|
||||
);
|
||||
|
||||
self
|
||||
@@ -1761,9 +1766,15 @@ impl ApiTester {
|
||||
}
|
||||
|
||||
pub async fn test_get_node_health(self) -> Self {
|
||||
let status = self.client.get_node_health().await.unwrap();
|
||||
assert_eq!(status, StatusCode::OK);
|
||||
|
||||
let status = self.client.get_node_health().await;
|
||||
match status {
|
||||
Ok(_) => {
|
||||
panic!("should return 503 error status code");
|
||||
}
|
||||
Err(e) => {
|
||||
assert_eq!(e.status().unwrap(), 503);
|
||||
}
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
@@ -4142,7 +4153,7 @@ impl ApiTester {
|
||||
.unwrap();
|
||||
|
||||
let expected_reorg = EventKind::ChainReorg(SseChainReorg {
|
||||
slot: self.next_block.signed_block().slot(),
|
||||
slot: self.reorg_block.slot(),
|
||||
depth: 1,
|
||||
old_head_block: self.next_block.signed_block().canonical_root(),
|
||||
old_head_state: self.next_block.signed_block().state_root(),
|
||||
@@ -4156,6 +4167,8 @@ impl ApiTester {
|
||||
execution_optimistic: false,
|
||||
});
|
||||
|
||||
self.harness.advance_slot();
|
||||
|
||||
self.client
|
||||
.post_beacon_blocks(&self.reorg_block)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user