Skip to content

Commit ae1a04a

Browse files
fix test
1 parent c795481 commit ae1a04a

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

beacon_node/network/src/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ impl<T: BeaconChainTypes> ToStatusMessage for BeaconChain<T> {
2828

2929
impl<T: BeaconChainTypes> ToStatusMessage for Arc<BeaconChain<T>> {
3030
fn status_message(&self) -> Result<StatusMessage, BeaconChainError> {
31-
<BeaconChain<T> as ToStatusMessage>::status_message(&self)
31+
<BeaconChain<T> as ToStatusMessage>::status_message(self)
3232
}
3333
}

beacon_node/network/src/sync/range_sync/chain_collection.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<T: BeaconChainTypes, C: BlockStorage> ChainCollection<T, C> {
7272
RangeSyncState::Finalized(ref syncing_id) => {
7373
if syncing_id == id {
7474
// the finalized chain that was syncing was removed
75-
debug_assert!(was_syncing);
75+
debug_assert!(was_syncing && sync_type == RangeSyncType::Finalized);
7676
let syncing_head_ids: SmallVec<[u64; PARALLEL_HEAD_CHAINS]> = self
7777
.head_chains
7878
.iter()
@@ -85,7 +85,8 @@ impl<T: BeaconChainTypes, C: BlockStorage> ChainCollection<T, C> {
8585
RangeSyncState::Head(syncing_head_ids)
8686
};
8787
} else {
88-
debug_assert!(!was_syncing);
88+
// we removed a head chain, or an stoped finalized chain
89+
debug_assert!(!was_syncing || sync_type != RangeSyncType::Finalized);
8990
}
9091
}
9192
RangeSyncState::Head(ref mut syncing_head_ids) => {

beacon_node/network/src/sync/range_sync/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
//! peers.
33
44
mod batch;
5+
mod block_storage;
56
mod chain;
67
mod chain_collection;
78
mod range;
89
mod sync_type;
9-
mod block_storage;
1010

1111
pub use batch::{BatchConfig, BatchInfo, BatchState};
1212
pub use chain::{BatchId, ChainId, EPOCHS_PER_BATCH};

beacon_node/network/src/sync/range_sync/range.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ mod tests {
430430
}
431431
}
432432

433+
#[allow(unused)]
433434
struct TestRig {
434435
log: slog::Logger,
435436
/// To check what does sync send to the beacon processor.
@@ -589,7 +590,8 @@ mod tests {
589590
}
590591

591592
#[test]
592-
fn sync() {
593+
fn head_chain_removed_while_finalized_syncing() {
594+
// NOTE: this is a regression test.
593595
let (mut rig, mut range) = range(true);
594596

595597
// Get a peer with an advanced head
@@ -610,5 +612,6 @@ mod tests {
610612

611613
// Fail the head chain by disconnecting the peer.
612614
range.remove_peer(&mut rig.cx, &head_peer);
615+
range.assert_state(RangeSyncType::Finalized);
613616
}
614617
}

0 commit comments

Comments
 (0)