From fc538ec2ea3e426dcfa69a9426eddf359716b49b Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Fri, 16 Dec 2016 13:50:55 -0700 Subject: [PATCH] Add test for IncrementalMerkleTree::size(). --- src/gtest/test_merkletree.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gtest/test_merkletree.cpp b/src/gtest/test_merkletree.cpp index efe5587e5..cf1d8617a 100644 --- a/src/gtest/test_merkletree.cpp +++ b/src/gtest/test_merkletree.cpp @@ -79,6 +79,9 @@ void test_tree( // The tree doesn't have a 'last' element added since it's blank. ASSERT_THROW(tree.last(), std::runtime_error); + // The tree is empty. + ASSERT_TRUE(tree.size() == 0); + // We need to witness at every single point in the tree, so // that the consistency of the tree and the merkle paths can // be checked. @@ -93,6 +96,9 @@ void test_tree( // Now append a commitment to the tree tree.append(test_commitment); + // Size incremented by one. + ASSERT_TRUE(tree.size() == i+1); + // Last element added to the tree was `test_commitment` ASSERT_TRUE(tree.last() == test_commitment);