2
2
// Distributed under the MIT software license, see the accompanying
3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
//
5
- #include < txmempool.h>
6
- #include < validation.h>
7
5
#include < sync.h>
8
6
#include < test/util/setup_common.h>
7
+ #include < txmempool.h>
8
+ #include < validation.h>
9
9
10
10
#include < boost/test/unit_test.hpp>
11
11
@@ -85,12 +85,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
85
85
// This is contingent not only on the dynamic memory usage of the Coins
86
86
// that we're adding (COIN_SIZE bytes per), but also on how much memory the
87
87
// 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 };
94
89
95
90
for (int i{0 }; i < COINS_UNTIL_CRITICAL; ++i) {
96
91
COutPoint res = add_coin (view);
@@ -101,17 +96,14 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
101
96
CoinsCacheSizeState::OK);
102
97
}
103
98
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) {
113
101
add_coin (view);
114
102
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
+ }
115
107
}
116
108
117
109
BOOST_CHECK_EQUAL (
0 commit comments