Skip to content

Commit faca8ef

Browse files
author
MarcoFalke
committed
test: Remove incorrect assumptions in validation_flush_tests
1 parent fa31eeb commit faca8ef

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/test/validation_flush_tests.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
//
5-
#include <txmempool.h>
6-
#include <validation.h>
75
#include <sync.h>
86
#include <test/util/setup_common.h>
7+
#include <txmempool.h>
8+
#include <validation.h>
99

1010
#include <boost/test/unit_test.hpp>
1111

@@ -85,12 +85,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
8585
// This is contingent not only on the dynamic memory usage of the Coins
8686
// that we're adding (COIN_SIZE bytes per), but also on how much memory the
8787
// cacheCoins (unordered_map) preallocates.
88-
//
89-
// I came up with the count by examining the printed memory usage of the
90-
// CCoinsCacheView, so it's sort of arbitrary - but it shouldn't change
91-
// unless we somehow change the way the cacheCoins map allocates memory.
92-
//
93-
constexpr int COINS_UNTIL_CRITICAL = is_64_bit ? 4 : 5;
88+
constexpr int COINS_UNTIL_CRITICAL{3};
9489

9590
for (int i{0}; i < COINS_UNTIL_CRITICAL; ++i) {
9691
COutPoint res = add_coin(view);
@@ -101,17 +96,14 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
10196
CoinsCacheSizeState::OK);
10297
}
10398

104-
// Adding an additional coin will push us over the edge to CRITICAL.
105-
add_coin(view);
106-
print_view_mem_usage(view);
107-
108-
auto size_state = chainstate.GetCoinsCacheSizeState(
109-
tx_pool, MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 0);
110-
111-
if (!is_64_bit && size_state == CoinsCacheSizeState::LARGE) {
112-
// On 32 bit hosts, we may hit LARGE before CRITICAL.
99+
// Adding some additional coins will push us over the edge to CRITICAL.
100+
for (int i{0}; i < 4; ++i) {
113101
add_coin(view);
114102
print_view_mem_usage(view);
103+
if (chainstate.GetCoinsCacheSizeState(tx_pool, MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 0) ==
104+
CoinsCacheSizeState::CRITICAL) {
105+
break;
106+
}
115107
}
116108

117109
BOOST_CHECK_EQUAL(

0 commit comments

Comments
 (0)