diff options
Diffstat (limited to 'ripple/fossil/src')
-rw-r--r-- | ripple/fossil/src/lib.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ripple/fossil/src/lib.rs b/ripple/fossil/src/lib.rs index 37df3bd..d7818cd 100644 --- a/ripple/fossil/src/lib.rs +++ b/ripple/fossil/src/lib.rs @@ -242,3 +242,21 @@ pub fn digest_from_bytes(bytes: &[u8]) -> Digest { buffer.copy_from_slice(bytes); buffer.into() } + +#[test] +/// Write a blob, and read it back. +fn read_write() { + let data = { + let mut h = blake3::Hasher::new(); + h.update(b"test vector"); + + let mut buf = Vec::new(); + h.finalize_xof().take(2468).read_to_end(&mut buf).unwrap(); + buf + }; + + // TODO(edef): use a temporary file + let store = Store::open("fossil.db").unwrap(); + let ident = store.write_blob(&data); + assert_eq!(data, store.read_blob(ident)); +} |