From e96b2c58c737fdd4ca3fed5fd14cd3453a00c649 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 25 Oct 2024 00:39:20 +0200 Subject: [PATCH] add test_get_item_exists --- utxo/src/utxo_tree.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/utxo/src/utxo_tree.rs b/utxo/src/utxo_tree.rs index b9ffa53..8b28de1 100644 --- a/utxo/src/utxo_tree.rs +++ b/utxo/src/utxo_tree.rs @@ -133,4 +133,17 @@ mod tests { assert!(smt.curr_root.is_some()); } + #[test] + fn test_get_item_exists() { + let mut smt = UTXOSparseMerkleTree::new(); + let utxo = sample_utxo(); + + smt.insert_item(utxo.clone()).unwrap(); + + // Test that the UTXO can be retrieved by hash + let retrieved_utxo = smt.get_item(utxo.hash).unwrap(); + assert!(retrieved_utxo.is_some()); + assert_eq!(retrieved_utxo.unwrap().hash, utxo.hash); + } + }