mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
validation tests: Use existing {Chainstate,Block}Man
Use {Chain,}TestingSetup's existing {Chainstate,Block}Manager and avoid unnecessarily creating a local one. This also helps reduce the code diff for a later commit where we change {Chainstate,Block}Manager's constructor signature.
This commit is contained in:
parent
a6fc293c0a
commit
2e79fb6585
2 changed files with 4 additions and 18 deletions
|
@ -9,7 +9,6 @@
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <test/util/chainstate.h>
|
#include <test/util/chainstate.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <timedata.h>
|
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
|
@ -17,19 +16,13 @@
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE(validation_chainstate_tests, TestingSetup)
|
BOOST_FIXTURE_TEST_SUITE(validation_chainstate_tests, ChainTestingSetup)
|
||||||
|
|
||||||
//! Test resizing coins-related CChainState caches during runtime.
|
//! Test resizing coins-related CChainState caches during runtime.
|
||||||
//!
|
//!
|
||||||
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
|
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
|
||||||
{
|
{
|
||||||
const ChainstateManager::Options chainman_opts{
|
ChainstateManager& manager = *Assert(m_node.chainman);
|
||||||
.chainparams = Params(),
|
|
||||||
.adjusted_time_callback = GetAdjustedTime,
|
|
||||||
};
|
|
||||||
ChainstateManager manager{chainman_opts};
|
|
||||||
|
|
||||||
WITH_LOCK(::cs_main, manager.m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(1 << 20, true));
|
|
||||||
CTxMemPool& mempool = *Assert(m_node.mempool);
|
CTxMemPool& mempool = *Assert(m_node.mempool);
|
||||||
|
|
||||||
//! Create and add a Coin with DynamicMemoryUsage of 80 bytes to the given view.
|
//! Create and add a Coin with DynamicMemoryUsage of 80 bytes to the given view.
|
||||||
|
|
|
@ -4,14 +4,11 @@
|
||||||
//
|
//
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <txmempool.h>
|
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
using node::BlockManager;
|
BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, TestingSetup)
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, ChainTestingSetup)
|
|
||||||
|
|
||||||
//! Test utilities for detecting when we need to flush the coins cache based
|
//! Test utilities for detecting when we need to flush the coins cache based
|
||||||
//! on estimated memory usage.
|
//! on estimated memory usage.
|
||||||
|
@ -20,11 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, ChainTestingSetup)
|
||||||
//!
|
//!
|
||||||
BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
|
BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
|
||||||
{
|
{
|
||||||
CTxMemPool& mempool = *Assert(m_node.mempool);
|
CChainState& chainstate{m_node.chainman->ActiveChainstate()};
|
||||||
BlockManager blockman{};
|
|
||||||
CChainState chainstate{&mempool, blockman, *Assert(m_node.chainman)};
|
|
||||||
chainstate.InitCoinsDB(/*cache_size_bytes=*/1 << 10, /*in_memory=*/true, /*should_wipe=*/false);
|
|
||||||
WITH_LOCK(::cs_main, chainstate.InitCoinsCache(1 << 10));
|
|
||||||
|
|
||||||
constexpr bool is_64_bit = sizeof(void*) == 8;
|
constexpr bool is_64_bit = sizeof(void*) == 8;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue