diff --git a/Cargo.toml b/Cargo.toml index 033a3cc..25668d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ serde = { version = "1", optional = true, features = ["derive"] } borsh = { version = "1", features = ["derive"], optional = true } [dev-dependencies] +nmt-rs = { path = ".", features = ["borsh", "serde"]} borsh = { version = "1" } serde_json = "1.0.96" postcard = { version = "1.0.4" } diff --git a/src/namespaced_hash.rs b/src/namespaced_hash.rs index d1832d5..f9e1df5 100644 --- a/src/namespaced_hash.rs +++ b/src/namespaced_hash.rs @@ -399,14 +399,12 @@ impl TryFrom<&[u8]> for NamespacedHash { mod tests { use crate::NamespacedHash; use borsh::de::BorshDeserialize; - use borsh::ser::BorshSerialize; #[test] fn test_namespaced_hash_borsh() { let hash = NamespacedHash::<8>::try_from([8u8; 48].as_ref()).unwrap(); - let serialized = hash - .try_to_vec() + let serialized = borsh::to_vec(&hash) .expect("Serialization to vec must succeed"); let got = diff --git a/src/simple_merkle/tree.rs b/src/simple_merkle/tree.rs index 24b6e32..07aa2a1 100644 --- a/src/simple_merkle/tree.rs +++ b/src/simple_merkle/tree.rs @@ -79,6 +79,17 @@ pub trait MerkleHash { + serde::Serialize + serde::de::DeserializeOwned; + #[cfg(all(not(feature = "serde"), feature = "borsh", feature = "std"))] + type Output: Debug + + PartialEq + + Eq + + Clone + + Default + + Hash + + Ord + + borsh::BorshSerialize + + borsh::BorshDeserialize; + /// The output of this hasher #[cfg(all(feature = "serde", feature = "borsh", feature = "std"))] type Output: Debug