Changeset View
Changeset View
Standalone View
Standalone View
src/test/coins_tests.cpp
Show First 20 Lines • Show All 771 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
// Simple wrapper for CheckAddCoinBase function above that loops through | // Simple wrapper for CheckAddCoinBase function above that loops through | ||||
// different possible base_values, making sure each one gives the same results. | // different possible base_values, making sure each one gives the same results. | ||||
// This wrapper lets the coin_add test below be shorter and less repetitive, | // This wrapper lets the coin_add test below be shorter and less repetitive, | ||||
// while still verifying that the CoinsViewCache::AddCoin implementation ignores | // while still verifying that the CoinsViewCache::AddCoin implementation ignores | ||||
// base values. | // base values. | ||||
template <typename... Args> static void CheckAddCoin(Args &&... args) { | template <typename... Args> static void CheckAddCoin(Args &&... args) { | ||||
for (Amount base_value : {ABSENT, PRUNED, VALUE1}) { | for (const Amount base_value : {ABSENT, PRUNED, VALUE1}) { | ||||
CheckAddCoinBase(base_value, std::forward<Args>(args)...); | CheckAddCoinBase(base_value, std::forward<Args>(args)...); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(coin_add) { | BOOST_AUTO_TEST_CASE(coin_add) { | ||||
/** | /** | ||||
* Check AddCoin behavior, requesting a new coin from a cache view, writing | * Check AddCoin behavior, requesting a new coin from a cache view, writing | ||||
* a modification to the coin, and then checking the resulting entry in the | * a modification to the coin, and then checking the resulting entry in the | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(coin_write) { | ||||
CheckWriteCoin(VALUE1, VALUE2, VALUE2, DIRTY | FRESH, DIRTY, DIRTY | FRESH); | CheckWriteCoin(VALUE1, VALUE2, VALUE2, DIRTY | FRESH, DIRTY, DIRTY | FRESH); | ||||
CheckWriteCoin(VALUE1, VALUE2, FAIL, DIRTY | FRESH, DIRTY | FRESH, | CheckWriteCoin(VALUE1, VALUE2, FAIL, DIRTY | FRESH, DIRTY | FRESH, | ||||
NO_ENTRY); | NO_ENTRY); | ||||
// The checks above omit cases where the child flags are not DIRTY, since | // The checks above omit cases where the child flags are not DIRTY, since | ||||
// they would be too repetitive (the parent cache is never updated in these | // they would be too repetitive (the parent cache is never updated in these | ||||
// cases). The loop below covers these cases and makes sure the parent cache | // cases). The loop below covers these cases and makes sure the parent cache | ||||
// is always left unchanged. | // is always left unchanged. | ||||
for (Amount parent_value : {ABSENT, PRUNED, VALUE1}) { | for (const Amount parent_value : {ABSENT, PRUNED, VALUE1}) { | ||||
for (Amount child_value : {ABSENT, PRUNED, VALUE2}) { | for (const Amount child_value : {ABSENT, PRUNED, VALUE2}) { | ||||
for (char parent_flags : | for (const char parent_flags : | ||||
parent_value == ABSENT ? ABSENT_FLAGS : FLAGS) { | parent_value == ABSENT ? ABSENT_FLAGS : FLAGS) { | ||||
for (char child_flags : | for (const char child_flags : | ||||
child_value == ABSENT ? ABSENT_FLAGS : CLEAN_FLAGS) { | child_value == ABSENT ? ABSENT_FLAGS : CLEAN_FLAGS) { | ||||
CheckWriteCoin(parent_value, child_value, parent_value, | CheckWriteCoin(parent_value, child_value, parent_value, | ||||
parent_flags, child_flags, parent_flags); | parent_flags, child_flags, parent_flags); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |