Bitcoin Core
31.99.0
P2P Digital Currency
src
test
caches_tests.cpp
Go to the documentation of this file.
1
// Copyright (c) The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or https://opensource.org/license/mit.
4
5
#include <
node/caches.h
>
6
#include <
util/byte_units.h
>
7
8
#include <boost/test/unit_test.hpp>
9
10
using namespace
node
;
11
12
BOOST_AUTO_TEST_SUITE(caches_tests)
13
14
BOOST_AUTO_TEST_CASE
(oversized_dbcache_warning)
15
{
16
// memory restricted setup - cap is DEFAULT_DB_CACHE (450 MiB)
17
BOOST_CHECK
(!
ShouldWarnOversizedDbCache
(
/*dbcache=*/
4_MiB,
/*total_ram=*/
1_GiB));
// Under cap
18
BOOST_CHECK
(
ShouldWarnOversizedDbCache
(
/*dbcache=*/
512_MiB,
/*total_ram=*/
1_GiB));
// At cap
19
BOOST_CHECK
(
ShouldWarnOversizedDbCache
(
/*dbcache=*/
1500_MiB,
/*total_ram=*/
1_GiB));
// Over cap
20
21
// 2 GiB RAM - cap is 75%
22
BOOST_CHECK
(!
ShouldWarnOversizedDbCache
(
/*dbcache=*/
1500_MiB,
/*total_ram=*/
2_GiB));
// Under cap
23
BOOST_CHECK
(
ShouldWarnOversizedDbCache
(
/*dbcache=*/
1600_MiB,
/*total_ram=*/
2_GiB));
// Over cap
24
25
// 4 GiB RAM - cap is 75%
26
BOOST_CHECK
(!
ShouldWarnOversizedDbCache
(
/*dbcache=*/
2500_MiB,
/*total_ram=*/
4_GiB));
// Under cap
27
BOOST_CHECK
(
ShouldWarnOversizedDbCache
(
/*dbcache=*/
3500_MiB,
/*total_ram=*/
4_GiB));
// Over cap
28
29
// 8 GiB RAM - cap is 75%
30
BOOST_CHECK
(!
ShouldWarnOversizedDbCache
(
/*dbcache=*/
6000_MiB,
/*total_ram=*/
8_GiB));
// Under cap
31
BOOST_CHECK
(
ShouldWarnOversizedDbCache
(
/*dbcache=*/
7000_MiB,
/*total_ram=*/
8_GiB));
// Over cap
32
33
// 16 GiB RAM - cap is 75%
34
BOOST_CHECK
(!
ShouldWarnOversizedDbCache
(
/*dbcache=*/
10_GiB,
/*total_ram=*/
16_GiB));
// Under cap
35
BOOST_CHECK
(
ShouldWarnOversizedDbCache
(
/*dbcache=*/
15_GiB,
/*total_ram=*/
16_GiB));
// Over cap
36
37
// 32 GiB RAM - cap is 75%
38
BOOST_CHECK
(!
ShouldWarnOversizedDbCache
(
/*dbcache=*/
20_GiB,
/*total_ram=*/
32_GiB));
// Under cap
39
BOOST_CHECK
(
ShouldWarnOversizedDbCache
(
/*dbcache=*/
30_GiB,
/*total_ram=*/
32_GiB));
// Over cap
40
}
41
42
BOOST_AUTO_TEST_SUITE_END
()
byte_units.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(oversized_dbcache_warning)
Definition:
caches_tests.cpp:14
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
node
Definition:
messages.h:21
node::ShouldWarnOversizedDbCache
constexpr bool ShouldWarnOversizedDbCache(uint64_t dbcache, uint64_t total_ram) noexcept
Definition:
caches.h:32
caches.h
BOOST_CHECK
#define BOOST_CHECK(expr)
Definition:
object.cpp:16
Generated on Thu May 14 2026 20:00:42 for Bitcoin Core by
1.9.4