Merge bitcoin/bitcoin#28050: test: make assumeUTXO test capture the expected fatal error

3e8bf2e10c test: make assumeUTXO test capture the expected fatal error (furszy)

Pull request description:

  The test is exercising the error, so it can capture it before the
  test framework displays it on the console as an unforeseen
  fatal error.

  It is odd to observe a fatal error after executing the complete
  test suite and seeing it pass successfully.

  Reproduction Steps:
  Run the unit test suite. A long AssumeUTXO fatal error will be
  printed even when all tests pass successfully.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 3e8bf2e10c
  theStack:
    Tested ACK 3e8bf2e10c
  TheCharlatan:
    ACK 3e8bf2e10c

Tree-SHA512: 820a5a4db52085ed72cbe7eb433b8c0f2d283ac6f5d456bc2b3e3f0305301022b2729e32e5fd9002859e4491ae7ac6de568a4c20557c7b249b0e7694ab8bd177
This commit is contained in:
fanquake 2023-07-10 16:08:32 +01:00
commit c464e67e0b
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -10,6 +10,7 @@
#include <rpc/blockchain.h>
#include <sync.h>
#include <test/util/chainstate.h>
#include <test/util/logging.h>
#include <test/util/random.h>
#include <test/util/setup_common.h>
#include <timedata.h>
@ -659,8 +660,11 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_snapshot_completion_hash_mismatch, Sna
fs::path snapshot_chainstate_dir = gArgs.GetDataDirNet() / "chainstate_snapshot";
BOOST_CHECK(fs::exists(snapshot_chainstate_dir));
res = WITH_LOCK(::cs_main, return chainman.MaybeCompleteSnapshotValidation());
BOOST_CHECK_EQUAL(res, SnapshotCompletionResult::HASH_MISMATCH);
{
ASSERT_DEBUG_LOG("failed to validate the -assumeutxo snapshot state");
res = WITH_LOCK(::cs_main, return chainman.MaybeCompleteSnapshotValidation());
BOOST_CHECK_EQUAL(res, SnapshotCompletionResult::HASH_MISMATCH);
}
auto all_chainstates = chainman.GetAll();
BOOST_CHECK_EQUAL(all_chainstates.size(), 1);