feat: added MerkleStore serde

This commit is contained in:
Augusto F. Hack
2023-03-24 19:36:51 +01:00
parent 854892ba9d
commit 7957cc929a
2 changed files with 57 additions and 0 deletions

View File

@@ -5,6 +5,9 @@ use crate::{
Felt, Word,
};
#[cfg(std)]
use std::error::Error;
const KEYS4: [u64; 4] = [0, 1, 2, 3];
const LEAVES4: [Word; 4] = [
int_to_node(1),
@@ -554,3 +557,12 @@ fn test_constructors() -> Result<(), MerkleError> {
Ok(())
}
#[cfg(std)]
#[test]
fn test_serialization() -> Result<(), Box<dyn Error>> {
let original = MerkleStore::new().with_merkle_tree(LEAVES4)?;
let decoded = MerkleStore::read_from_bytes(&original.to_bytes())?;
assert_eq!(original, decoded);
Ok(())
}