Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
citizen-stig committed Jun 28, 2024
1 parent da215e1 commit cfd9ea2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
4 changes: 1 addition & 3 deletions src/namespaced_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,12 @@ impl<const NS_ID_SIZE: usize> TryFrom<&[u8]> for NamespacedHash<NS_ID_SIZE> {
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 =
Expand Down
11 changes: 11 additions & 0 deletions src/simple_merkle/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cfd9ea2

Please sign in to comment.