1#[macro_use]
7extern crate tracing;
8
9mod block;
10mod config;
11mod db;
12mod encoding;
13mod implementation;
14mod key_value;
15mod retry;
16mod storage;
17mod store;
18mod tap;
19mod ucan;
20
21pub use crate::ucan::*;
22pub use block::*;
23pub use config::*;
24pub use db::*;
25pub use encoding::*;
26pub use implementation::*;
27pub use key_value::*;
28pub use retry::*;
29pub use storage::*;
30pub use store::*;
31pub use tap::*;
32
33mod space;
34pub use space::*;
35
36#[cfg(test)]
37pub mod helpers;
38
39#[cfg(test)]
40mod tests {
41 use crate::{block::BlockStore, helpers::make_disposable_store};
42
43 use libipld_cbor::DagCborCodec;
44 #[cfg(target_arch = "wasm32")]
45 use wasm_bindgen_test::wasm_bindgen_test;
46
47 wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
48
49 #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
50 #[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
51 async fn it_can_store_and_retrieve_bytes() {
52 let mut storage = make_disposable_store().await.unwrap();
53 let bytes = b"I love every kind of cat";
54
55 let cid = storage.save::<DagCborCodec, _>(bytes).await.unwrap();
56 let retrieved = storage.load::<DagCborCodec, Vec<u8>>(&cid).await.unwrap();
57
58 assert_eq!(retrieved, bytes);
59 }
60}