From fad381b2f8e1beb18f748fbeb820e63545b9b0fd Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 5 Jan 2022 16:25:43 +0100 Subject: [PATCH] test: Load genesis block to allow flush This is needed to turn globals into member variables. Otherwise, this will lead to issues: runtime error: reference binding to null pointer of type 'CBlockFileInfo' #0 in std::vector >::operator[](unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_vector.h:1046:2 #1 in BlockManager::FlushBlockFile(bool, bool) src/node/blockstorage.cpp:540:47 #2 in CChainState::FlushStateToDisk(BlockValidationState&, FlushStateMode, int) src/validation.cpp:2262:28 #3 in CChainState::ResizeCoinsCaches(unsigned long, unsigned long) src/validation.cpp:4414:15 #4 in validation_chainstate_tests::validation_chainstate_resize_caches::test_method() src/test/validation_chainstate_tests.cpp:66:12 --- src/test/validation_chainstate_tests.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/validation_chainstate_tests.cpp b/src/test/validation_chainstate_tests.cpp index 4be568ab47d7d..1beef5cf04bef 100644 --- a/src/test/validation_chainstate_tests.cpp +++ b/src/test/validation_chainstate_tests.cpp @@ -43,6 +43,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches) c1.InitCoinsDB( /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false); WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23)); + BOOST_REQUIRE(c1.LoadGenesisBlock()); // Need at least one block loaded to be able to flush caches // Add a coin to the in-memory cache, upsize once, then downsize. {