diff options
| author | Russell Yanofsky <[email protected]> | 2020-04-15 17:07:44 -0400 |
|---|---|---|
| committer | Russell Yanofsky <[email protected]> | 2020-04-15 17:07:44 -0400 |
| commit | 9986608ba93de040490ee0d5584ea33e605f1df0 (patch) | |
| tree | 1777a14d9a81dc6dbdb1314c29f139c76738d2f9 /src/test/interfaces_tests.cpp | |
| parent | Merge #18615: test: Avoid accessing free'd memory in validation_chainstateman... (diff) | |
| download | discoin-9986608ba93de040490ee0d5584ea33e605f1df0.tar.xz discoin-9986608ba93de040490ee0d5584ea33e605f1df0.zip | |
test: Verify findCommonAncestor always initializes outputs
Also add code comment to clarify surprising code noted by practicalswift
https://github.com/bitcoin/bitcoin/pull/18657#issuecomment-614278450
Diffstat (limited to 'src/test/interfaces_tests.cpp')
| -rw-r--r-- | src/test/interfaces_tests.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/test/interfaces_tests.cpp b/src/test/interfaces_tests.cpp index fab357175..b0d4de89f 100644 --- a/src/test/interfaces_tests.cpp +++ b/src/test/interfaces_tests.cpp @@ -116,6 +116,12 @@ BOOST_AUTO_TEST_CASE(findCommonAncestor) BOOST_CHECK_EQUAL(orig_height, orig_tip->nHeight); BOOST_CHECK_EQUAL(fork_height, orig_tip->nHeight - 10); BOOST_CHECK_EQUAL(fork_hash, active[fork_height]->GetBlockHash()); + + uint256 active_hash, orig_hash; + BOOST_CHECK(!chain->findCommonAncestor(active.Tip()->GetBlockHash(), {}, {}, FoundBlock().hash(active_hash), {})); + BOOST_CHECK(!chain->findCommonAncestor({}, orig_tip->GetBlockHash(), {}, {}, FoundBlock().hash(orig_hash))); + BOOST_CHECK_EQUAL(active_hash, active.Tip()->GetBlockHash()); + BOOST_CHECK_EQUAL(orig_hash, orig_tip->GetBlockHash()); } BOOST_AUTO_TEST_CASE(hasBlocks) |