Write range sync tests in external event-driven form (#6618)

* Write range sync tests in external event-driven form

* Fix remaining test

* Drop unused generics

* Merge branch 'unstable' into range-sync-tests

* Add reference to test author

* Use async await

* Fix failing test. Not sure how it was passing before without an EL.
This commit is contained in:
Lion - dapplion
2024-12-16 13:44:10 +08:00
committed by GitHub
parent 75d90795be
commit 1c5be34def
8 changed files with 328 additions and 512 deletions

View File

@@ -83,6 +83,7 @@ impl TestRig {
.logger(log.clone())
.deterministic_keypairs(1)
.fresh_ephemeral_store()
.mock_execution_layer()
.testing_slot_clock(TestingSlotClock::new(
Slot::new(0),
Duration::from_secs(0),
@@ -144,7 +145,7 @@ impl TestRig {
}
}
fn test_setup() -> Self {
pub fn test_setup() -> Self {
Self::test_setup_with_config(None)
}
@@ -168,11 +169,11 @@ impl TestRig {
}
}
fn log(&self, msg: &str) {
pub fn log(&self, msg: &str) {
info!(self.log, "TEST_RIG"; "msg" => msg);
}
fn after_deneb(&self) -> bool {
pub fn after_deneb(&self) -> bool {
matches!(self.fork_name, ForkName::Deneb | ForkName::Electra)
}
@@ -238,7 +239,7 @@ impl TestRig {
(parent, block, parent_root, block_root)
}
fn send_sync_message(&mut self, sync_message: SyncMessage<E>) {
pub fn send_sync_message(&mut self, sync_message: SyncMessage<E>) {
self.sync_manager.handle_message(sync_message);
}
@@ -369,7 +370,7 @@ impl TestRig {
self.expect_empty_network();
}
fn new_connected_peer(&mut self) -> PeerId {
pub fn new_connected_peer(&mut self) -> PeerId {
self.network_globals
.peers
.write()
@@ -811,7 +812,7 @@ impl TestRig {
}
}
fn peer_disconnected(&mut self, peer_id: PeerId) {
pub fn peer_disconnected(&mut self, peer_id: PeerId) {
self.send_sync_message(SyncMessage::Disconnect(peer_id));
}
@@ -827,7 +828,7 @@ impl TestRig {
}
}
fn pop_received_network_event<T, F: Fn(&NetworkMessage<E>) -> Option<T>>(
pub fn pop_received_network_event<T, F: Fn(&NetworkMessage<E>) -> Option<T>>(
&mut self,
predicate_transform: F,
) -> Result<T, String> {
@@ -847,7 +848,7 @@ impl TestRig {
}
}
fn pop_received_processor_event<T, F: Fn(&WorkEvent<E>) -> Option<T>>(
pub fn pop_received_processor_event<T, F: Fn(&WorkEvent<E>) -> Option<T>>(
&mut self,
predicate_transform: F,
) -> Result<T, String> {
@@ -871,6 +872,16 @@ impl TestRig {
}
}
pub fn expect_empty_processor(&mut self) {
self.drain_processor_rx();
if !self.beacon_processor_rx_queue.is_empty() {
panic!(
"Expected processor to be empty, but has events: {:?}",
self.beacon_processor_rx_queue
);
}
}
fn find_block_lookup_request(
&mut self,
for_block: Hash256,
@@ -2173,7 +2184,8 @@ fn custody_lookup_happy_path() {
mod deneb_only {
use super::*;
use beacon_chain::{
block_verification_types::RpcBlock, data_availability_checker::AvailabilityCheckError,
block_verification_types::{AsBlock, RpcBlock},
data_availability_checker::AvailabilityCheckError,
};
use ssz_types::VariableList;
use std::collections::VecDeque;