From 552b285b2f6bbcdbb74ee39577b2d345423dc23d Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 25 Oct 2024 00:39:33 +0200 Subject: [PATCH] add test_get_item_not_exists --- utxo/src/utxo_tree.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/utxo/src/utxo_tree.rs b/utxo/src/utxo_tree.rs index 8b28de1..462ed9f 100644 --- a/utxo/src/utxo_tree.rs +++ b/utxo/src/utxo_tree.rs @@ -146,4 +146,19 @@ mod tests { assert_eq!(retrieved_utxo.unwrap().hash, utxo.hash); } + #[test] + fn test_get_item_not_exists() { + let mut smt = UTXOSparseMerkleTree::new(); + let utxo = sample_utxo(); + + // Insert one UTXO and try to fetch a different hash + smt.insert_item(utxo).unwrap(); + + let non_existent_hash = TreeHashType::default(); + let result = smt.get_item(non_existent_hash).unwrap(); + + // Test that retrieval for a non-existent UTXO returns None + assert!(result.is_none()); + } + }