From f54b3a9c3112ea192fe37217de97f03adb13ced9 Mon Sep 17 00:00:00 2001 From: rurumimic <10915235+rurumimic@users.noreply.github.com> Date: Sun, 15 Oct 2023 16:46:42 +0900 Subject: [PATCH] Implement Test for `root_of_single_item_tree()` --- core/src/merkle_tree.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/merkle_tree.rs b/core/src/merkle_tree.rs index 750337ba..93470db8 100644 --- a/core/src/merkle_tree.rs +++ b/core/src/merkle_tree.rs @@ -208,7 +208,12 @@ mod test { #[test] /// Check the root of the tree with a single item, with the manual calculation. fn root_of_single_item_tree() { - // TODO + let key: Hash256 = Hash256::hash("hello world"); + let merkle_tree: OneshotMerkleTree = OneshotMerkleTree::create(Vec::from([key])); + let root_hash: Hash256 = OneshotMerkleTree::root(&merkle_tree); + + assert!(root_hash == key); + assert!(merkle_tree.hash_list.len() == 1); } #[test]