5#include <boost/test/unit_test.hpp>
18 std::vector<CTransactionRef> block_vtx(m_coinbase_txns);
25 std::unordered_map<uint256, CTransaction*, SaltedTxidHasher> temp_map;
28 temp_map.reserve(100);
32 for (
const auto& tx : block_vtx)
37 const size_t ENTRY_USAGE_ESTIMATE{
43 +
sizeof(
decltype(temp_map)::value_type))};
50 std::vector<CTransactionRef> two_txns({block_vtx.at(0), block_vtx.at(1)});
52 BOOST_CHECK(disconnectpool.DynamicMemoryUsage() <= MAP_1 + ENTRY_USAGE_ESTIMATE);
59 disconnectpool.clear();
66 const size_t USAGE_100_OVERESTIMATE{MAP_100 + ENTRY_USAGE_ESTIMATE * 100};
70 BOOST_CHECK(disconnectpool.DynamicMemoryUsage() <= USAGE_100_OVERESTIMATE);
72 usage_full = disconnectpool.DynamicMemoryUsage();
74 disconnectpool.clear();
79 const size_t MAX_MEMUSAGE_99{usage_full -
sizeof(
void*)};
82 BOOST_CHECK(disconnectpool.DynamicMemoryUsage() <= MAX_MEMUSAGE_99);
91 disconnectpool.clear();
DisconnectedBlockTransactions.
std::vector< CTransactionRef > AddTransactionsFromBlock(const std::vector< CTransactionRef > &vtx)
Add transactions from the block, iterating through vtx in reverse order.
static size_t RecursiveDynamicUsage(const CScript &script)
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
static size_t DynamicUsage(const int8_t &v)
Dynamic memory usage for built-in types is zero.
static size_t MallocUsage(size_t alloc)
Compute the total memory used by allocating alloc bytes.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
BOOST_AUTO_TEST_CASE(disconnectpool_memory_limits)
Tests that DisconnectedBlockTransactions limits its own memory properly.