From 535bb1011ecffac2dc73b75bd5174a150fc2690b Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 18 Oct 2024 10:42:18 +0200 Subject: [PATCH] fmt --- storage/src/merkle_tree_public/merkle_tree.rs | 58 ++++++++++++++----- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/storage/src/merkle_tree_public/merkle_tree.rs b/storage/src/merkle_tree_public/merkle_tree.rs index 73e9e75..16d185e 100644 --- a/storage/src/merkle_tree_public/merkle_tree.rs +++ b/storage/src/merkle_tree_public/merkle_tree.rs @@ -116,15 +116,19 @@ mod tests { let mut buffer = [0u8; 32]; let bytes = s.as_bytes(); let len = std::cmp::min(32, bytes.len()); - + buffer[..len].copy_from_slice(&bytes[..len]); buffer } #[test] fn test_new_merkle_tree() { - let tx1 = MockTransaction { hash: get_first_32_bytes("tx1") }; - let tx2 = MockTransaction { hash: get_first_32_bytes("tx2") }; + let tx1 = MockTransaction { + hash: get_first_32_bytes("tx1"), + }; + let tx2 = MockTransaction { + hash: get_first_32_bytes("tx2"), + }; let tree = HashStorageMerkleTree::new(vec![tx1.clone(), tx2.clone()]); @@ -134,8 +138,12 @@ mod tests { #[test] fn test_get_tx() { - let tx1 = MockTransaction { hash: get_first_32_bytes("tx1") }; - let tx2 = MockTransaction { hash: get_first_32_bytes("tx2") }; + let tx1 = MockTransaction { + hash: get_first_32_bytes("tx1"), + }; + let tx2 = MockTransaction { + hash: get_first_32_bytes("tx2"), + }; let tree = HashStorageMerkleTree::new(vec![tx1.clone(), tx2.clone()]); @@ -145,8 +153,12 @@ mod tests { #[test] fn test_get_proof() { - let tx1 = MockTransaction { hash: get_first_32_bytes("tx1") }; - let tx2 = MockTransaction { hash: get_first_32_bytes("tx2") }; + let tx1 = MockTransaction { + hash: get_first_32_bytes("tx1"), + }; + let tx2 = MockTransaction { + hash: get_first_32_bytes("tx2"), + }; let tree = HashStorageMerkleTree::new(vec![tx1.clone(), tx2.clone()]); @@ -156,8 +168,12 @@ mod tests { #[test] fn test_add_tx() { - let tx1 = MockTransaction { hash: get_first_32_bytes("tx1") }; - let tx2 = MockTransaction { hash: get_first_32_bytes("tx2") }; + let tx1 = MockTransaction { + hash: get_first_32_bytes("tx1"), + }; + let tx2 = MockTransaction { + hash: get_first_32_bytes("tx2"), + }; let mut tree = HashStorageMerkleTree::new(vec![tx1.clone()]); @@ -168,9 +184,15 @@ mod tests { #[test] fn test_add_tx_multiple() { - let tx1 = MockTransaction { hash: get_first_32_bytes("tx1") }; - let tx2 = MockTransaction { hash: get_first_32_bytes("tx2") }; - let tx3 = MockTransaction { hash: get_first_32_bytes("tx3") }; + let tx1 = MockTransaction { + hash: get_first_32_bytes("tx1"), + }; + let tx2 = MockTransaction { + hash: get_first_32_bytes("tx2"), + }; + let tx3 = MockTransaction { + hash: get_first_32_bytes("tx3"), + }; let mut tree = HashStorageMerkleTree::new(vec![tx1.clone()]); tree.add_tx_multiple(vec![tx2.clone(), tx3.clone()]); @@ -182,9 +204,15 @@ mod tests { #[test] fn test_get_proof_multiple() { - let tx1 = MockTransaction { hash: get_first_32_bytes("tx1") }; - let tx2 = MockTransaction { hash: get_first_32_bytes("tx2") }; - let tx3 = MockTransaction { hash: get_first_32_bytes("tx3") }; + let tx1 = MockTransaction { + hash: get_first_32_bytes("tx1"), + }; + let tx2 = MockTransaction { + hash: get_first_32_bytes("tx2"), + }; + let tx3 = MockTransaction { + hash: get_first_32_bytes("tx3"), + }; let tree = HashStorageMerkleTree::new(vec![tx1.clone(), tx2.clone(), tx3.clone()]); let proof = tree.get_proof_multiple(&[tx1.hash(), tx2.hash()]);