diff options
author | edef <edef@unfathomable.blue> | 2022-04-19 01:15:25 +0000 |
---|---|---|
committer | edef <edef@unfathomable.blue> | 2022-04-19 01:16:08 +0000 |
commit | 78c53cf327090dbfe70c9e73001dfde3bae8ddc5 (patch) | |
tree | 42e038dc15df0468f17983b99cac7a9cc7112af2 /ripple | |
parent | 42bf591ee5b0a397408f4e47d1ed5f702b3fec27 (diff) | |
download | unf-legacy-78c53cf327090dbfe70c9e73001dfde3bae8ddc5.tar.zst |
ripple/fossil: add read_write test
Change-Id: I88d13d9dd7055b8370706df7b3dd4479a0891399
Diffstat (limited to 'ripple')
-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)); +} |