Changeset View
Changeset View
Standalone View
Standalone View
src/test/coins_tests.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | bool GetCoin(const COutPoint &outpoint, Coin &coin) const { | ||||
coin = it->second; | coin = it->second; | ||||
if (coin.IsSpent() && insecure_rand() % 2 == 0) { | if (coin.IsSpent() && insecure_rand() % 2 == 0) { | ||||
// Randomly return false in case of an empty entry. | // Randomly return false in case of an empty entry. | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool HaveCoin(const COutPoint outpoint) const { | bool HaveCoin(const COutPoint &outpoint) const { | ||||
Coin coin; | Coin coin; | ||||
return GetCoin(outpoint, coin); | return GetCoin(outpoint, coin); | ||||
} | } | ||||
uint256 GetBestBlock() const { return hashBestBlock_; } | uint256 GetBestBlock() const { return hashBestBlock_; } | ||||
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { | bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { | ||||
for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) { | for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) { | ||||
Show All 31 Lines | void SelfTest() const { | ||||
} | } | ||||
BOOST_CHECK_EQUAL(GetCacheSize(), count); | BOOST_CHECK_EQUAL(GetCacheSize(), count); | ||||
BOOST_CHECK_EQUAL(DynamicMemoryUsage(), ret); | BOOST_CHECK_EQUAL(DynamicMemoryUsage(), ret); | ||||
} | } | ||||
CCoinsMap &map() { return cacheCoins; } | CCoinsMap &map() { return cacheCoins; } | ||||
size_t &usage() { return cachedCoinsUsage; } | size_t &usage() { return cachedCoinsUsage; } | ||||
}; | }; | ||||
} | } // namespace | ||||
BOOST_FIXTURE_TEST_SUITE(coins_tests, BasicTestingSetup) | BOOST_FIXTURE_TEST_SUITE(coins_tests, BasicTestingSetup) | ||||
static const unsigned int NUM_SIMULATION_ITERATIONS = 40000; | static const unsigned int NUM_SIMULATION_ITERATIONS = 40000; | ||||
// This is a large randomized insert/remove simulation test on a variable-size | // This is a large randomized insert/remove simulation test on a variable-size | ||||
// stack of caches on top of CCoinsViewTest. | // stack of caches on top of CCoinsViewTest. | ||||
// | // | ||||
▲ Show 20 Lines • Show All 791 Lines • Show Last 20 Lines |