Skip to content

Commit

Permalink
Fix tests checks and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienFT committed Nov 28, 2024
1 parent 193e0ac commit 10c8a21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
20 changes: 4 additions & 16 deletions crates/services/sync/src/import/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,8 @@ impl Cache {
.into_iter()
.filter_map(|chunk| {
let (range, blocks): (Vec<u32>, Vec<SealedBlock>) = chunk.unzip();
let Some(start_range) = range.get(0) else {
return None;
};
let Some(mut end_range) =
range.get(range.len().saturating_sub(1))
else {
return None;
};
let start_range = range.first()?;
let mut end_range = range.get(range.len().saturating_sub(1))?;
Some(CachedDataBatch::Blocks(Batch::new(
None,
*start_range..end_range.saturating_add(1),
Expand All @@ -164,14 +158,8 @@ impl Cache {
.filter_map(|chunk| {
let (range, headers): (Vec<u32>, Vec<SealedBlockHeader>) =
chunk.unzip();
let Some(start_range) = range.get(0) else {
return None;
};
let Some(mut end_range) =
range.get(range.len().saturating_sub(1))
else {
return None;
};
let start_range = range.first()?;
let mut end_range = range.get(range.len().saturating_sub(1))?;
Some(CachedDataBatch::Headers(Batch::new(
None,
*start_range..end_range.saturating_add(1),
Expand Down
8 changes: 4 additions & 4 deletions crates/services/sync/src/import/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ async fn import__keep_data_asked_in_fail_ask_header_cases() {
.times(1)
.in_sequence(&mut seq)
.returning(|range| {
assert_eq!(range, 4..4);
assert_eq!(range, 4..5);
Box::pin(async move {
tokio::time::sleep(Duration::from_millis(300)).await;
Err(anyhow::anyhow!("Some network error"))
Expand All @@ -299,7 +299,7 @@ async fn import__keep_data_asked_in_fail_ask_header_cases() {
.times(1)
.in_sequence(&mut seq)
.returning(|range| {
assert_eq!(range, 4..4);
assert_eq!(range, 4..5);
Box::pin(async move {
let peer = random_peer();
let headers = Some(range.map(empty_header).collect());
Expand Down Expand Up @@ -389,7 +389,7 @@ async fn import__keep_data_asked_in_fail_ask_transactions_cases() {
.times(1)
.in_sequence(&mut seq)
.returning(|range| {
assert_eq!(range.data, 4..4);
assert_eq!(range.data, 4..5);
Box::pin(async move {
tokio::time::sleep(Duration::from_millis(300)).await;
Err(anyhow::anyhow!("Some network error"))
Expand All @@ -413,7 +413,7 @@ async fn import__keep_data_asked_in_fail_ask_transactions_cases() {
.times(1)
.in_sequence(&mut seq)
.returning(|block_ids| {
assert_eq!(block_ids, 4..4);
assert_eq!(block_ids, 4..5);
Box::pin(async move {
let data = block_ids;
let v = data.into_iter().map(|_| Transactions::default()).collect();
Expand Down

0 comments on commit 10c8a21

Please sign in to comment.