Add test that `last` and `element` will throw exception when the tree is blank.

This commit is contained in:
Sean Bowe 2016-11-15 12:17:19 -07:00
parent d92bea9888
commit 3e2e8b5b42
1 changed files with 4 additions and 0 deletions

View File

@ -76,6 +76,9 @@ void test_tree(
// empty tree.
ASSERT_TRUE(tree.root() == Tree::empty_root());
// The tree doesn't have a 'last' element added since it's blank.
ASSERT_THROW(tree.last(), std::runtime_error);
// 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.
@ -107,6 +110,7 @@ void test_tree(
if (first) {
ASSERT_THROW(wit.path(), std::runtime_error);
ASSERT_THROW(wit.element(), std::runtime_error);
} else {
auto path = wit.path();