Skip to content

refactor: Remove slot mutex and simplfy per blob state #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: slim-down-state
Choose a base branch
from
Draft
41 changes: 40 additions & 1 deletion src/api/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,15 @@ mod tests {
use testresult::TestResult;

use crate::{
api::blobs::Blobs,
protocol::{ChunkRangesSeq, GetRequest},
store::fs::{tests::INTERESTING_SIZES, FsStore},
store::{
fs::{
tests::{create_n0_bao, test_data, INTERESTING_SIZES},
FsStore,
},
mem::MemStore,
},
tests::{add_test_hash_seq, add_test_hash_seq_incomplete},
util::ChunkRangesExt,
};
Expand Down Expand Up @@ -1117,6 +1124,38 @@ mod tests {
Ok(())
}

async fn test_observe_partial(blobs: &Blobs) -> TestResult<()> {
let sizes = INTERESTING_SIZES;
for size in sizes {
let data = test_data(size);
let ranges = ChunkRanges::chunk(0);
let (hash, bao) = create_n0_bao(&data, &ranges)?;
blobs.import_bao_bytes(hash, ranges.clone(), bao).await?;
let bitfield = blobs.observe(hash).await?;
if size > 1024 {
assert_eq!(bitfield.ranges, ranges);
} else {
assert_eq!(bitfield.ranges, ChunkRanges::all());
}
}
Ok(())
}

#[tokio::test]
async fn test_observe_partial_mem() -> TestResult<()> {
let store = MemStore::new();
test_observe_partial(store.blobs()).await?;
Ok(())
}

#[tokio::test]
async fn test_observe_partial_fs() -> TestResult<()> {
let td = tempfile::tempdir()?;
let store = FsStore::load(td.path()).await?;
test_observe_partial(store.blobs()).await?;
Ok(())
}

#[tokio::test]
async fn test_local_info_hash_seq() -> TestResult<()> {
let sizes = INTERESTING_SIZES;
Expand Down
Loading
Loading