Skip to content

Commit

Permalink
Update test to reflect that if a block is valid in fork_db, its ances…
Browse files Browse the repository at this point in the history
…tors are as well.
  • Loading branch information
greg7mdp committed Sep 18, 2024
1 parent 9bde458 commit 45e67aa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions unittests/fork_db_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,15 @@ BOOST_FIXTURE_TEST_CASE(add_remove_test, generate_forkdb_state) try {
// test `fork_database_t::validated_block_exists() const` member
// -------------------------------------------------------------
BOOST_FIXTURE_TEST_CASE(validated_block_exists, generate_forkdb_state) try {

// if a block is valid in fork_db, all its ancestors are necessarily valid.
root->set_valid(true);
bsp11b->set_valid(true);
bsp12b->set_valid(true);
bsp13b->set_valid(true);
bsp14b->set_valid(true);
bsp11a->set_valid(true);

bsp13a->set_valid(false);

BOOST_REQUIRE_EQUAL(true, forkdb.validated_block_exists(bsp14b->id(), bsp14b->id()));
BOOST_REQUIRE_EQUAL(true, forkdb.validated_block_exists(bsp14b->id(), bsp13b->id()));
Expand All @@ -164,17 +169,17 @@ BOOST_FIXTURE_TEST_CASE(validated_block_exists, generate_forkdb_state) try {
BOOST_REQUIRE_EQUAL(true, forkdb.validated_block_exists(bsp14b->id(), bsp12b->id()));
BOOST_REQUIRE_EQUAL(true, forkdb.validated_block_exists(bsp14b->id(), bsp11b->id()));

bsp12b->set_valid(false);
bsp13b->set_valid(false);
BOOST_REQUIRE_EQUAL(false, forkdb.validated_block_exists(bsp14b->id(), bsp14b->id()));
BOOST_REQUIRE_EQUAL(true, forkdb.validated_block_exists(bsp14b->id(), bsp13b->id()));
BOOST_REQUIRE_EQUAL(false, forkdb.validated_block_exists(bsp14b->id(), bsp13b->id()));
BOOST_REQUIRE_EQUAL(true, forkdb.validated_block_exists(bsp14b->id(), bsp12b->id()));
BOOST_REQUIRE_EQUAL(true, forkdb.validated_block_exists(bsp14b->id(), bsp11b->id()));

bsp13b->set_valid(false);
bsp12b->set_valid(false);
BOOST_REQUIRE_EQUAL(false, forkdb.validated_block_exists(bsp14b->id(), bsp14b->id()));
BOOST_REQUIRE_EQUAL(false, forkdb.validated_block_exists(bsp14b->id(), bsp13b->id()));
BOOST_REQUIRE_EQUAL(false, forkdb.validated_block_exists(bsp14b->id(), bsp12b->id()));
BOOST_REQUIRE_EQUAL(false, forkdb.validated_block_exists(bsp14b->id(), bsp11b->id()));
BOOST_REQUIRE_EQUAL(true, forkdb.validated_block_exists(bsp14b->id(), bsp11b->id()));

bsp11b->set_valid(false);
BOOST_REQUIRE_EQUAL(false, forkdb.validated_block_exists(bsp14b->id(), bsp14b->id()));
Expand Down

0 comments on commit 45e67aa

Please sign in to comment.