Skip to content

Commit 93cc3a7

Browse files
Tom Trevethandelta1
authored andcommitted
Replaced check for initial memory allocations of coinscache with the updated upstream version, meaning dynamic memory usage (and difference on macos/clang) is not checked if not a common case (32/16). All other checks now pass on both macos, linux and windows.
(cherry picked from commit 6c3b0da)
1 parent 2ec510d commit 93cc3a7

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

src/test/validation_flush_tests.cpp

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
4646
// If the initial memory allocations of cacheCoins don't match these common
4747
// cases, we can't really continue to make assertions about memory usage.
4848
// End the test early.
49-
// ELEMENTS: These tests are fragile even on Bitcoin, as evidenced by
50-
// the wide numeric ranges which are set ad-hoc all over the place.
51-
// I tried probably 30 times to change the values so that they'd work
52-
// on Cirrus for Elements, but there are just too many of values and it
53-
// is impossible to guess the exact memory usage of libstd collections
54-
// on CI boxes, and they change whenever I tweak other memory-related
55-
// parameters. So instead I'm just forcing (in a way the compiler won't
56-
// recognize as an `if (true) { ... return }` block) the "unknown arch"
57-
// path, which does a simple/crude check and returns.
58-
//if (view.DynamicMemoryUsage() != 32 && view.DynamicMemoryUsage() != 16) {
59-
if (view.DynamicMemoryUsage() < 1000) {
49+
if (view.DynamicMemoryUsage() != 32 && view.DynamicMemoryUsage() != 16) {
6050
// Add a bunch of coins to see that we at least flip over to CRITICAL.
6151

6252
for (int i{0}; i < 1000; ++i) {
@@ -73,7 +63,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
7363
}
7464

7565
print_view_mem_usage(view);
76-
// BOOST_CHECK_EQUAL(view.DynamicMemoryUsage(), is_64_bit ? 262240U : 16U); // ELEMENTS FIXME differs on macos ci [262208 != 262240]
66+
BOOST_CHECK_EQUAL(view.DynamicMemoryUsage(), is_64_bit ? 32U : 16U);
7767

7868
// We should be able to add COINS_UNTIL_CRITICAL coins to the cache before going CRITICAL.
7969
// This is contingent not only on the dynamic memory usage of the Coins
@@ -82,10 +72,9 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
8272
constexpr int COINS_UNTIL_CRITICAL{3};
8373

8474
// no coin added, so we have plenty of space left.
85-
// ELEMENTS FIXME
86-
// BOOST_CHECK_EQUAL(
87-
// chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 0),
88-
// CoinsCacheSizeState::OK);
75+
BOOST_CHECK_EQUAL(
76+
chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 0),
77+
CoinsCacheSizeState::OK);
8978

9079
for (int i{0}; i < COINS_UNTIL_CRITICAL; ++i) {
9180
const COutPoint res = AddTestCoin(view);
@@ -160,10 +149,9 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
160149
BOOST_CHECK(view.Flush());
161150
print_view_mem_usage(view);
162151

163-
// ELEMENTS FIXME
164-
// BOOST_CHECK_EQUAL(
165-
// chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 0),
166-
// CoinsCacheSizeState::OK);
152+
BOOST_CHECK_EQUAL(
153+
chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 0),
154+
CoinsCacheSizeState::OK);
167155
}
168156

169-
BOOST_AUTO_TEST_SUITE_END()
157+
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)