7#include <boost/test/unit_test.hpp>
11BOOST_AUTO_TEST_SUITE(coinscachepair_tests)
17 std::list<CoinsCachePair> nodes;
21 auto node{std::prev(nodes.end())};
39 sentinel.second.SelfRef(sentinel);
43 auto node{sentinel.second.Next()};
44 for (
const auto& expected : nodes) {
52 node = sentinel.second.Next();
53 for (
const auto& expected : nodes) {
55 auto next =
node->second.Next();
56 node->second.SetClean();
65 for (
auto it{nodes.begin()}; it != nodes.end(); it = nodes.erase(it)) {
66 BOOST_CHECK(!it->second.IsDirty() && !it->second.IsFresh());
73 sentinel.second.SelfRef(sentinel);
79 auto node{sentinel.second.Next()};
80 for (
auto expected{nodes.begin()}; expected != nodes.end(); expected = nodes.erase(expected)) {
94 sentinel.second.SelfRef(sentinel);
98 auto n1{nodes.begin()};
99 auto n2{std::next(n1)};
100 auto n3{std::next(n2)};
101 auto n4{std::next(n3)};
108 BOOST_CHECK(n1->second.IsDirty() && !n1->second.IsFresh());
110 BOOST_CHECK(n3->second.IsDirty() && !n3->second.IsFresh());
119 BOOST_CHECK(n3->second.IsDirty() && !n3->second.IsFresh());
129 BOOST_CHECK(n3->second.IsDirty() && !n3->second.IsFresh());
145 sentinel.second.SelfRef(sentinel);
151 BOOST_CHECK(n1.second.IsDirty() && !n1.second.IsFresh());
159 BOOST_CHECK(n2.second.IsFresh() && !n2.second.IsDirty());
167 BOOST_CHECK(n1.second.IsDirty() && n1.second.IsFresh());
174 n1.second.SetClean();
175 BOOST_CHECK(!n1.second.IsDirty() && !n1.second.IsFresh());
182 n1.second.SetClean();
183 BOOST_CHECK(!n1.second.IsDirty() && !n1.second.IsFresh());
191 BOOST_CHECK(n1.second.IsDirty() && !n1.second.IsFresh());
std::pair< const COutPoint, CCoinsCacheEntry > CoinsCachePair
BOOST_AUTO_TEST_CASE(linked_list_iteration)
static constexpr auto NUM_NODES
std::list< CoinsCachePair > CreatePairs(CoinsCachePair &sentinel)
BOOST_AUTO_TEST_SUITE_END()
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
static void SetFresh(CoinsCachePair &pair, CoinsCachePair &sentinel) noexcept
static void SetDirty(CoinsCachePair &pair, CoinsCachePair &sentinel) noexcept