Skip to content

Commit e5d8b65

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25815: test: Use existing {Chainstate,Block}Man
2e79fb6 validation tests: Use existing {Chainstate,Block}Man (Carl Dong) Pull request description: This is split up because it is needed for two changes: * bitcoin/bitcoin#25781 * bitcoin/bitcoin#25623 ACKs for top commit: adam2k: ACK tested 2e79fb6 aureleoules: ACK 2e79fb6. Tree-SHA512: 2cd6a2fec19545f8ffc77e37ccb793aa6cb5815bb1b5e560c0345af6e0f890fd500ae3297b044d3f6f613b8dd7fd4553f5fc2824013342b9e25af1fe2b624967
2 parents e078ee9 + 2e79fb6 commit e5d8b65

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

src/test/validation_chainstate_tests.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,20 @@
99
#include <sync.h>
1010
#include <test/util/chainstate.h>
1111
#include <test/util/setup_common.h>
12-
#include <timedata.h>
1312
#include <uint256.h>
1413
#include <validation.h>
1514

1615
#include <vector>
1716

1817
#include <boost/test/unit_test.hpp>
1918

20-
BOOST_FIXTURE_TEST_SUITE(validation_chainstate_tests, TestingSetup)
19+
BOOST_FIXTURE_TEST_SUITE(validation_chainstate_tests, ChainTestingSetup)
2120

2221
//! Test resizing coins-related CChainState caches during runtime.
2322
//!
2423
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
2524
{
26-
const ChainstateManager::Options chainman_opts{
27-
.chainparams = Params(),
28-
.adjusted_time_callback = GetAdjustedTime,
29-
};
30-
ChainstateManager manager{chainman_opts};
31-
32-
WITH_LOCK(::cs_main, manager.m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(1 << 20, true));
25+
ChainstateManager& manager = *Assert(m_node.chainman);
3326
CTxMemPool& mempool = *Assert(m_node.mempool);
3427

3528
//! Create and add a Coin with DynamicMemoryUsage of 80 bytes to the given view.

src/test/validation_flush_tests.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
//
55
#include <sync.h>
66
#include <test/util/setup_common.h>
7-
#include <txmempool.h>
87
#include <validation.h>
98

109
#include <boost/test/unit_test.hpp>
1110

12-
using node::BlockManager;
13-
14-
BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, ChainTestingSetup)
11+
BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, TestingSetup)
1512

1613
//! Test utilities for detecting when we need to flush the coins cache based
1714
//! on estimated memory usage.
@@ -20,11 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, ChainTestingSetup)
2017
//!
2118
BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
2219
{
23-
CTxMemPool& mempool = *Assert(m_node.mempool);
24-
BlockManager blockman{};
25-
CChainState chainstate{&mempool, blockman, *Assert(m_node.chainman)};
26-
chainstate.InitCoinsDB(/*cache_size_bytes=*/1 << 10, /*in_memory=*/true, /*should_wipe=*/false);
27-
WITH_LOCK(::cs_main, chainstate.InitCoinsCache(1 << 10));
20+
CChainState& chainstate{m_node.chainman->ActiveChainstate()};
2821

2922
constexpr bool is_64_bit = sizeof(void*) == 8;
3023

0 commit comments

Comments
 (0)