Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
divagant-martian committed Nov 18, 2021
1 parent c795481 commit ae1a04a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion beacon_node/network/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ impl<T: BeaconChainTypes> ToStatusMessage for BeaconChain<T> {

impl<T: BeaconChainTypes> ToStatusMessage for Arc<BeaconChain<T>> {
fn status_message(&self) -> Result<StatusMessage, BeaconChainError> {
<BeaconChain<T> as ToStatusMessage>::status_message(&self)
<BeaconChain<T> as ToStatusMessage>::status_message(self)
}
}
5 changes: 3 additions & 2 deletions beacon_node/network/src/sync/range_sync/chain_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<T: BeaconChainTypes, C: BlockStorage> ChainCollection<T, C> {
RangeSyncState::Finalized(ref syncing_id) => {
if syncing_id == id {
// the finalized chain that was syncing was removed
debug_assert!(was_syncing);
debug_assert!(was_syncing && sync_type == RangeSyncType::Finalized);
let syncing_head_ids: SmallVec<[u64; PARALLEL_HEAD_CHAINS]> = self
.head_chains
.iter()
Expand All @@ -85,7 +85,8 @@ impl<T: BeaconChainTypes, C: BlockStorage> ChainCollection<T, C> {
RangeSyncState::Head(syncing_head_ids)
};
} else {
debug_assert!(!was_syncing);
// we removed a head chain, or an stoped finalized chain
debug_assert!(!was_syncing || sync_type != RangeSyncType::Finalized);
}
}
RangeSyncState::Head(ref mut syncing_head_ids) => {
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/network/src/sync/range_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
//! peers.
mod batch;
mod block_storage;
mod chain;
mod chain_collection;
mod range;
mod sync_type;
mod block_storage;

pub use batch::{BatchConfig, BatchInfo, BatchState};
pub use chain::{BatchId, ChainId, EPOCHS_PER_BATCH};
Expand Down
5 changes: 4 additions & 1 deletion beacon_node/network/src/sync/range_sync/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ mod tests {
}
}

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

#[test]
fn sync() {
fn head_chain_removed_while_finalized_syncing() {
// NOTE: this is a regression test.
let (mut rig, mut range) = range(true);

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

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

0 comments on commit ae1a04a

Please sign in to comment.