Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Boog900 committed Jun 13, 2024
1 parent cefd8a7 commit dd9e63d
Show file tree
Hide file tree
Showing 5 changed files with 368 additions and 54 deletions.
50 changes: 1 addition & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions p2p/cuprate-p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ dashmap = { workspace = true }

thiserror = { workspace = true }
bytes = { workspace = true, features = ["std"] }
indexmap = { workspace = true, features = ["std"] }
rand = { workspace = true, features = ["std", "std_rng"] }
rand_distr = { workspace = true, features = ["std"] }
hex = { workspace = true, features = ["std"] }
tracing = { workspace = true, features = ["std", "attributes"] }

tracing-subscriber = "0.3.18"

[dev-dependencies]
cuprate-test-utils = { path = "../../test-utils" }
indexmap = { workspace = true }
proptest = { workspace = true }
11 changes: 10 additions & 1 deletion p2p/cuprate-p2p/src/block_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! and downloads it.
//!
//! The block downloader is started by [`download_blocks`].
use futures::FutureExt;
use std::{
cmp::{max, min, Ordering, Reverse},
collections::{BTreeMap, BinaryHeap, HashSet},
Expand Down Expand Up @@ -46,6 +47,9 @@ use crate::{
mod chain_tracker;
use chain_tracker::{BlocksToRetrieve, ChainEntry, ChainTracker};

#[cfg(test)]
mod tests;

/// A downloaded batch of blocks.
#[derive(Debug)]
pub struct BlockBatch {
Expand Down Expand Up @@ -154,7 +158,12 @@ where
config,
);

tokio::spawn(block_downloader.run().instrument(Span::current()));
tokio::spawn(
block_downloader
.run()
.instrument(Span::current())
.map(|res| panic!("{res:?}")),
);

buffer_stream
}
Expand Down
Loading

0 comments on commit dd9e63d

Please sign in to comment.