| Crates.io | iroh-fake-store |
| lib.rs | iroh-fake-store |
| version | 0.1.1 |
| created_at | 2025-10-02 16:24:07.980093+00 |
| updated_at | 2025-10-02 17:55:51.209151+00 |
| description | a fake iroh-blobs store for testing that generates data on-the-fly without storage |
| homepage | |
| repository | https://github.com/arilotter/iroh-fake-store |
| max_upload_size | |
| id | 1864628 |
| size | 185,671 |
fake iroh-blobs store for testing. generates data on-the-fly without storing anything in RAM or disk.
for testing with large blobs (like 2TB) when you don't care about actual content. features:
iroh-blobs store protocol[dev-dependencies]
iroh-fake-store = "0.1"
use iroh_fake_store::FakeStore;
#[tokio::main]
async fn main() {
let store = FakeStore::new([
1024, // 1KB
1024 * 1024, // 1MB
1024 * 1024 * 1024, // 1GB
]);
let hashes = store.blobs().list().hashes().await.unwrap();
for hash in hashes {
let status = store.blobs().status(hash).await.unwrap();
println!("blob {} status: {:?}", hash, status);
}
}
use iroh_fake_store::{FakeStore, DataStrategy};
let store = FakeStore::builder()
.strategy(DataStrategy::PseudoRandom { seed: 42 })
.max_blob_size(Some(100 * 1024 * 1024)) // 100MB max
.with_blob(1024)
.with_blob(2048)
.build();
DataStrategy::Zeros: all zeros (default, most efficient)DataStrategy::Ones: all ones (0xFF)DataStrategy::PseudoRandom { seed }: deterministic pseudo-random// zeros (default)
let store = FakeStore::new([1024]);
// pseudo-random for more realistic testing
let store = FakeStore::builder()
.strategy(DataStrategy::PseudoRandom { seed: 12345 })
.with_blob(1024 * 1024)
.build();
test behavior with huge blobs without allocating memory:
use iroh_fake_store::FakeStore;
#[tokio::test]
async fn test_large_blob_transfer() {
// 2TB blob (doesn't actually allocate 2TB!)
let store = FakeStore::builder()
.max_blob_size(None) // remove size limit
.with_blob(2 * 1024 * 1024 * 1024 * 1024)
.build();
// test your transfer logic here...
}
default 10GB max to prevent accidents:
// this will panic!
let store = FakeStore::builder()
.with_blob(100 * 1024 * 1024 * 1024) // exceeds 10GB limit
.build();
// remove limit explicitly if you want huge blobs
let store = FakeStore::builder()
.max_blob_size(None)
.with_blob(100 * 1024 * 1024 * 1024) // now ok
.build();
implements full iroh-blobs store protocol:
dual-licensed under MIT or Apache-2.0