@@ -21,7 +21,7 @@ std::list<CoinsCachePair> CreatePairs(CoinsCachePair& sentinel)
21
21
auto node{std::prev (nodes.end ())};
22
22
CCoinsCacheEntry::SetDirty (*node, sentinel);
23
23
24
- BOOST_CHECK_EQUAL (node->second .GetFlags (), CCoinsCacheEntry::DIRTY );
24
+ BOOST_CHECK (node->second .IsDirty () && !node-> second . IsFresh () );
25
25
BOOST_CHECK_EQUAL (node->second .Next (), &sentinel);
26
26
BOOST_CHECK_EQUAL (sentinel.second .Prev (), &(*node));
27
27
@@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE(linked_list_iteration)
48
48
BOOST_CHECK_EQUAL (node, &sentinel);
49
49
50
50
// Check iterating through pairs is identical to iterating through a list
51
- // Clear the flags during iteration
51
+ // Clear the state during iteration
52
52
node = sentinel.second .Next ();
53
53
for (const auto & expected : nodes) {
54
54
BOOST_CHECK_EQUAL (&expected, node);
@@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(linked_list_iteration)
63
63
64
64
// Delete the nodes from the list to make sure there are no dangling pointers
65
65
for (auto it{nodes.begin ()}; it != nodes.end (); it = nodes.erase (it)) {
66
- BOOST_CHECK_EQUAL ( it->second .GetFlags (), 0 );
66
+ BOOST_CHECK (! it->second .IsDirty () && !it-> second . IsFresh () );
67
67
}
68
68
}
69
69
@@ -74,8 +74,8 @@ BOOST_AUTO_TEST_CASE(linked_list_iterate_erase)
74
74
auto nodes{CreatePairs (sentinel)};
75
75
76
76
// Check iterating through pairs is identical to iterating through a list
77
- // Erase the nodes as we iterate through, but don't clear flags
78
- // The flags will be cleared by the CCoinsCacheEntry's destructor
77
+ // Erase the nodes as we iterate through, but don't clear state
78
+ // The state will be cleared by the CCoinsCacheEntry's destructor
79
79
auto node{sentinel.second .Next ()};
80
80
for (auto expected{nodes.begin ()}; expected != nodes.end (); expected = nodes.erase (expected)) {
81
81
BOOST_CHECK_EQUAL (&(*expected), node);
@@ -104,19 +104,19 @@ BOOST_AUTO_TEST_CASE(linked_list_random_deletion)
104
104
// sentinel->n1->n3->n4->sentinel
105
105
nodes.erase (n2);
106
106
// Check that n1 now points to n3, and n3 still points to n4
107
- // Also check that flags were not altered
108
- BOOST_CHECK_EQUAL (n1->second .GetFlags (), CCoinsCacheEntry::DIRTY );
107
+ // Also check that state was not altered
108
+ BOOST_CHECK (n1->second .IsDirty () && !n1-> second . IsFresh () );
109
109
BOOST_CHECK_EQUAL (n1->second .Next (), &(*n3));
110
- BOOST_CHECK_EQUAL (n3->second .GetFlags (), CCoinsCacheEntry::DIRTY );
110
+ BOOST_CHECK (n3->second .IsDirty () && !n3-> second . IsFresh () );
111
111
BOOST_CHECK_EQUAL (n3->second .Next (), &(*n4));
112
112
BOOST_CHECK_EQUAL (n3->second .Prev (), &(*n1));
113
113
114
114
// Delete n1
115
115
// sentinel->n3->n4->sentinel
116
116
nodes.erase (n1);
117
117
// Check that sentinel now points to n3, and n3 still points to n4
118
- // Also check that flags were not altered
119
- BOOST_CHECK_EQUAL (n3->second .GetFlags (), CCoinsCacheEntry::DIRTY );
118
+ // Also check that state was not altered
119
+ BOOST_CHECK (n3->second .IsDirty () && !n3-> second . IsFresh () );
120
120
BOOST_CHECK_EQUAL (sentinel.second .Next (), &(*n3));
121
121
BOOST_CHECK_EQUAL (n3->second .Next (), &(*n4));
122
122
BOOST_CHECK_EQUAL (n3->second .Prev (), &sentinel);
@@ -125,8 +125,8 @@ BOOST_AUTO_TEST_CASE(linked_list_random_deletion)
125
125
// sentinel->n3->sentinel
126
126
nodes.erase (n4);
127
127
// Check that sentinel still points to n3, and n3 points to sentinel
128
- // Also check that flags were not altered
129
- BOOST_CHECK_EQUAL (n3->second .GetFlags (), CCoinsCacheEntry::DIRTY );
128
+ // Also check that state was not altered
129
+ BOOST_CHECK (n3->second .IsDirty () && !n3-> second . IsFresh () );
130
130
BOOST_CHECK_EQUAL (sentinel.second .Next (), &(*n3));
131
131
BOOST_CHECK_EQUAL (n3->second .Next (), &sentinel);
132
132
BOOST_CHECK_EQUAL (sentinel.second .Prev (), &(*n3));
@@ -139,56 +139,56 @@ BOOST_AUTO_TEST_CASE(linked_list_random_deletion)
139
139
BOOST_CHECK_EQUAL (sentinel.second .Prev (), &sentinel);
140
140
}
141
141
142
- BOOST_AUTO_TEST_CASE (linked_list_add_flags )
142
+ BOOST_AUTO_TEST_CASE (linked_list_set_state )
143
143
{
144
144
CoinsCachePair sentinel;
145
145
sentinel.second .SelfRef (sentinel);
146
146
CoinsCachePair n1;
147
147
CoinsCachePair n2;
148
148
149
- // Check that adding DIRTY flag inserts it into linked list and sets flags
149
+ // Check that setting DIRTY inserts it into linked list and sets state
150
150
CCoinsCacheEntry::SetDirty (n1, sentinel);
151
- BOOST_CHECK_EQUAL (n1.second .GetFlags (), CCoinsCacheEntry::DIRTY );
151
+ BOOST_CHECK (n1.second .IsDirty () && !n1. second . IsFresh () );
152
152
BOOST_CHECK_EQUAL (n1.second .Next (), &sentinel);
153
153
BOOST_CHECK_EQUAL (n1.second .Prev (), &sentinel);
154
154
BOOST_CHECK_EQUAL (sentinel.second .Next (), &n1);
155
155
BOOST_CHECK_EQUAL (sentinel.second .Prev (), &n1);
156
156
157
- // Check that adding FRESH flag on new node inserts it after n1
157
+ // Check that setting FRESH on new node inserts it after n1
158
158
CCoinsCacheEntry::SetFresh (n2, sentinel);
159
- BOOST_CHECK_EQUAL (n2.second .GetFlags (), CCoinsCacheEntry::FRESH );
159
+ BOOST_CHECK (n2.second .IsFresh () && !n2. second . IsDirty () );
160
160
BOOST_CHECK_EQUAL (n2.second .Next (), &sentinel);
161
161
BOOST_CHECK_EQUAL (n2.second .Prev (), &n1);
162
162
BOOST_CHECK_EQUAL (n1.second .Next (), &n2);
163
163
BOOST_CHECK_EQUAL (sentinel.second .Prev (), &n2);
164
164
165
- // Check that we can add extra flags , but they don't change our position
165
+ // Check that we can set extra state , but they don't change our position
166
166
CCoinsCacheEntry::SetFresh (n1, sentinel);
167
- BOOST_CHECK_EQUAL (n1.second .GetFlags (), CCoinsCacheEntry::DIRTY | CCoinsCacheEntry::FRESH );
167
+ BOOST_CHECK (n1.second .IsDirty () && n1. second . IsFresh () );
168
168
BOOST_CHECK_EQUAL (n1.second .Next (), &n2);
169
169
BOOST_CHECK_EQUAL (n1.second .Prev (), &sentinel);
170
170
BOOST_CHECK_EQUAL (sentinel.second .Next (), &n1);
171
171
BOOST_CHECK_EQUAL (n2.second .Prev (), &n1);
172
172
173
- // Check that we can clear flags then re-add them
173
+ // Check that we can clear state then re-set it
174
174
n1.second .SetClean ();
175
- BOOST_CHECK_EQUAL ( n1.second .GetFlags (), 0 );
175
+ BOOST_CHECK (! n1.second .IsDirty () && !n1. second . IsFresh () );
176
176
BOOST_CHECK_EQUAL (sentinel.second .Next (), &n2);
177
177
BOOST_CHECK_EQUAL (sentinel.second .Prev (), &n2);
178
178
BOOST_CHECK_EQUAL (n2.second .Next (), &sentinel);
179
179
BOOST_CHECK_EQUAL (n2.second .Prev (), &sentinel);
180
180
181
- // Check that calling `SetClean` with 0 flags has no effect
181
+ // Calling `SetClean` a second time has no effect
182
182
n1.second .SetClean ();
183
- BOOST_CHECK_EQUAL ( n1.second .GetFlags (), 0 );
183
+ BOOST_CHECK (! n1.second .IsDirty () && !n1. second . IsFresh () );
184
184
BOOST_CHECK_EQUAL (sentinel.second .Next (), &n2);
185
185
BOOST_CHECK_EQUAL (sentinel.second .Prev (), &n2);
186
186
BOOST_CHECK_EQUAL (n2.second .Next (), &sentinel);
187
187
BOOST_CHECK_EQUAL (n2.second .Prev (), &sentinel);
188
188
189
189
// Adding DIRTY re-inserts it after n2
190
190
CCoinsCacheEntry::SetDirty (n1, sentinel);
191
- BOOST_CHECK_EQUAL (n1.second .GetFlags (), CCoinsCacheEntry::DIRTY );
191
+ BOOST_CHECK (n1.second .IsDirty () && !n1. second . IsFresh () );
192
192
BOOST_CHECK_EQUAL (n2.second .Next (), &n1);
193
193
BOOST_CHECK_EQUAL (n1.second .Prev (), &n2);
194
194
BOOST_CHECK_EQUAL (n1.second .Next (), &sentinel);
0 commit comments