MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CheckAddCoin

Function CheckAddCoin

src/test/coins_tests.cpp:747–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

745}
746
747static void CheckAddCoin(const CAmount base_value, const MaybeCoin& cache_coin, const CAmount modify_value, const CoinOrError& expected, const bool coinbase)
748{
749 SingleEntryCacheTest test{base_value, cache_coin};
750 bool possible_overwrite{coinbase};
751 auto add_coin{[&] { test.cache.AddCoin(OUTPOINT, Coin{CTxOut{modify_value, CScript{}}, 1, coinbase}, possible_overwrite); }};
752 if (auto* expected_coin{std::get_if<MaybeCoin>(&expected)}) {
753 add_coin();
754 test.cache.SelfTest();
755 BOOST_CHECK_EQUAL(GetCoinsMapEntry(test.cache.map()), *expected_coin);
756 } else {
757 BOOST_CHECK_EXCEPTION(add_coin(), std::logic_error, HasReason(std::get<std::string>(expected)));
758 }
759}
760
761BOOST_AUTO_TEST_CASE(ccoins_add)
762{

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 5

GetCoinsMapEntryFunction · 0.85
HasReasonClass · 0.85
AddCoinMethod · 0.80
SelfTestMethod · 0.80
add_coinFunction · 0.50

Tested by

no test coverage detected