Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
test_trx_finality_status_processing.cpp File Reference
#include <boost/test/included/unit_test.hpp>
#include <sysio/chain_plugin/trx_finality_status_processing.hpp>
#include <sysio/testing/tester.hpp>
#include <sysio/chain/block_header.hpp>
#include <sysio/chain/genesis_state.hpp>
#include <sysio/chain/name.hpp>
#include <sysio/chain/trace.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <fc/mock_time.hpp>
#include <fc/bitutil.hpp>
#include <deque>
#include <memory>
Include dependency graph for test_trx_finality_status_processing.cpp:

Go to the source code of this file.

Classes

struct  sysio::test::detail::testit
 

Namespaces

namespace  sysio
 
namespace  sysio::test
 
namespace  sysio::test::detail
 

Macros

#define BOOST_TEST_MODULE   transaction_finality_status
 

Functions

 BOOST_AUTO_TEST_CASE (trx_finality_status_logic)
 
 BOOST_AUTO_TEST_CASE (trx_finality_status_storage_reduction)
 
 BOOST_AUTO_TEST_CASE (trx_finality_status_lifespan)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   transaction_finality_status

Definition at line 1 of file test_trx_finality_status_processing.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( trx_finality_status_lifespan )

Definition at line 1121 of file test_trx_finality_status_processing.cpp.

1121 { try {
1122 set_now("2022-04-04", "04:44:44.450");
1123 fc::microseconds max_success_duration = fc::seconds(25);
1124 fc::microseconds max_failure_duration = fc::seconds(35);
1125 const uint64_t max_storage = 10'000;
1126 trx_finality_status_processing status(max_storage, max_success_duration, max_failure_duration);
1127
1128 // auto verify_trx = [&status](trx_deque& trx_pairs, const sysio::chain::block_state_ptr& bs) {
1129 // const auto id = bs ? bs->id : sysio::chain::transaction_id_type{};
1130 // for (const auto& trx_pair : trx_pairs) {
1131 // auto ts = status.get_trx_state(std::get<1>(trx_pair)->id());
1132 // BOOST_REQUIRE(ts);
1133 // BOOST_CHECK(ts->block_id == id);
1134 // }
1135 // };
1136
1137
1138 block_frame b_01(status, "04:44:00.500", 1);
1139 b_01.send_spec_block();
1140 b_01.verify_spec_block();
1141
1142 b_01.send_block();
1143 b_01.verify_block();
1144
1145
1146 block_frame b_02(status, "04:44:05.500");
1147 b_02.send_spec_block();
1148 b_02.verify_spec_block();
1149
1150 b_02.send_block();
1151 b_02.verify_block();
1152
1153
1154 block_frame b_03(status, "04:44:10.500");
1155 b_03.send_spec_block();
1156 b_03.verify_spec_block();
1157
1158 b_03.send_block();
1159 b_03.verify_block();
1160
1161
1162 block_frame b_04(status, "04:44:15.500");
1163 b_04.send_spec_block();
1164 b_04.verify_spec_block();
1165
1166 b_04.send_block();
1167 b_04.verify_block();
1168
1169
1170 block_frame b_05(status, "04:44:20.500");
1171 b_05.send_spec_block();
1172 b_05.verify_spec_block();
1173
1174 b_05.send_block();
1175 b_05.verify_block();
1176
1177 // should be still available
1178 b_01.verify_block();
1179 b_01.verify_spec_block(); // still available and will continue till failure time
1180
1181
1182 block_frame b_06(status, "04:44:25.500");
1183 b_06.send_spec_block();
1184 b_06.verify_spec_block();
1185
1186 b_06.send_block();
1187 b_06.verify_block();
1188
1189 // block 1 now removed
1190 b_01.verify_block_not_there();
1191 b_02.verify_block();
1192 b_01.verify_spec_block();
1193
1194 auto cs = status.get_chain_state();
1195 BOOST_CHECK(cs.head_id == b_06.bs->id);
1196 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
1197 BOOST_CHECK(cs.earliest_tracked_block_id == b_02.bs->id);
1198
1199
1200 block_frame b_07(status, "04:44:30.500");
1201 b_07.send_spec_block();
1202 b_07.verify_spec_block();
1203
1204 b_07.send_block();
1205 b_07.verify_block();
1206
1207 // block 2 now removed
1208 b_02.verify_block_not_there();
1209 b_03.verify_block();
1210 b_01.verify_spec_block();
1211 b_02.verify_spec_block();
1212
1213 cs = status.get_chain_state();
1214 BOOST_CHECK(cs.head_id == b_07.bs->id);
1215 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
1216 BOOST_CHECK(cs.earliest_tracked_block_id == b_03.bs->id);
1217
1218
1219 block_frame b_08(status, "04:44:35.500");
1220 b_08.send_spec_block();
1221 b_08.verify_spec_block();
1222
1223 b_08.send_block();
1224 b_08.verify_block();
1225
1226 // block 3 now removed and speculative's from block 1 time frame
1227 b_03.verify_block_not_there();
1228 b_04.verify_block();
1229 b_01.verify_spec_block_not_there();
1230 b_02.verify_spec_block();
1231 b_03.verify_spec_block();
1232
1233
1234 block_frame b_09(status, "04:44:40.500");
1235 b_09.send_spec_block();
1236 b_09.verify_spec_block();
1237
1238 b_09.send_block();
1239 b_09.verify_block();
1240
1241 // block 4 now removed and speculative's from block 2 time frame
1242 b_04.verify_block_not_there();
1243 b_05.verify_block();
1244 b_02.verify_spec_block_not_there();
1245 b_03.verify_spec_block();
1246 b_04.verify_spec_block();
1247
1248
1249 block_frame b_10(status, "04:44:45.500");
1250 b_10.send_spec_block();
1251 b_10.verify_spec_block();
1252
1253 b_10.send_block();
1254 b_10.verify_block();
1255
1256 // block 5 now removed and speculative's from block 3 time frame
1257 b_05.verify_block_not_there();
1258 b_06.verify_block();
1259 b_03.verify_spec_block_not_there();
1260 b_04.verify_spec_block();
1261 b_05.verify_spec_block();
1262
#define FC_LOG_AND_RETHROW()
static const Segment cs(Segment::cs)
constexpr microseconds seconds(int64_t s)
Definition time.hpp:32
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( trx_finality_status_logic )

Definition at line 167 of file test_trx_finality_status_processing.cpp.

167 { try {
168 const auto pre_block_20_time = set_now("2022-04-04", "04:44:44.450");
169 fc::microseconds max_success_duration = fc::seconds(25);
170 fc::microseconds max_failure_duration = fc::seconds(45);
171 trx_finality_status_processing status(10'000, max_success_duration, max_failure_duration);
172
173 using trx_deque = sysio::chain::deque< std::tuple< chain::transaction_trace_ptr, packed_transaction_ptr > >;
174
175 uint32_t bn = 20;
176 auto add = [&bn, &status](trx_deque& trx_pairs, const sysio::chain::block_state_ptr& bs_ptr) {
177 auto trx = make_unique_trx(fc::seconds(2));
178 auto trace = make_transaction_trace( trx, bn, bs_ptr);
179 trx_pairs.push_back(std::tuple(trace, trx));
180 status.signal_applied_transaction(trace, trx);
181 };
182
183 trx_deque trx_pairs_20;
184
185 // Create speculative block to begin applying transactions locally
186 status.signal_block_start(bn);
188
189 add(trx_pairs_20, no_bs);
190 add(trx_pairs_20, no_bs);
191 add(trx_pairs_20, no_bs);
192 add(trx_pairs_20, no_bs);
193
194 auto cs = status.get_chain_state();
195 BOOST_CHECK(cs.head_id == sysio::chain::block_id_type{});
196 BOOST_TEST(!std::get<0>(trx_pairs_20[0])->producer_block_id.has_value());
197 BOOST_CHECK(cs.head_block_timestamp == sysio::chain::block_timestamp_type{});
198 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
199 BOOST_CHECK(cs.earliest_tracked_block_id == sysio::chain::block_id_type{});
200
201 using op_ts = std::optional<sysio::chain_apis::trx_finality_status_processing::trx_state>;
202
203 op_ts ts = status.get_trx_state(std::get<1>(trx_pairs_20[0])->id());
204 BOOST_REQUIRE(ts);
205 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
206 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
207 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
208 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
209
210 ts = status.get_trx_state(std::get<1>(trx_pairs_20[1])->id());
211 BOOST_REQUIRE(ts);
212 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
213 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
214 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
215 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
216
217 ts = status.get_trx_state(std::get<1>(trx_pairs_20[2])->id());
218 BOOST_REQUIRE(ts);
219 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
220 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
221 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
222 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
223
224 ts = status.get_trx_state(std::get<1>(trx_pairs_20[3])->id());
225 BOOST_REQUIRE(ts);
226 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
227 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
228 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
229 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
230
231 // Simulate situation where the last 2 trxs do not make it into the block.
232 trx_deque hold_pairs;
233 std::vector<chain::packed_transaction_ptr> holds;
234 hold_pairs.push_back(trx_pairs_20[2]);
235 hold_pairs.push_back(trx_pairs_20[3]);
236 trx_pairs_20.pop_back();
237 trx_pairs_20.pop_back();
238
239 //Make a real block start. Pull these before any updates to the trx/trace objects.
240 // send block 20
241 const auto bs_20 = make_block_state(bn);
242 status.signal_block_start(bn);
243
244 for (const auto& trx_tuple : trx_pairs_20) {
245 const auto& trace = std::get<0>(trx_tuple);
246 const auto& txn = std::get<1>(trx_tuple);
247
248 trace->producer_block_id = bs_20->id;
249 trace->block_time = bs_20->block->timestamp;
250
251 status.signal_applied_transaction(trace, txn);
252 }
253
254 // and 2 new transactions
255 const auto block_20_time = set_now("2022-04-04", "04:44:44.500");
256 add(trx_pairs_20, bs_20);
257 add(trx_pairs_20, bs_20);
258 status.signal_accepted_block(bs_20);
259
260
261 cs = status.get_chain_state();
262 BOOST_CHECK(cs.head_id == bs_20->id);
263 BOOST_CHECK(cs.head_id == *std::get<0>(trx_pairs_20[0])->producer_block_id);
264 BOOST_CHECK(cs.head_id == *std::get<0>(trx_pairs_20[1])->producer_block_id);
265 BOOST_CHECK(cs.head_id == *std::get<0>(trx_pairs_20[2])->producer_block_id);
266 BOOST_CHECK(cs.head_id == *std::get<0>(trx_pairs_20[3])->producer_block_id);
267 BOOST_CHECK(cs.head_block_timestamp == bs_20->block->timestamp);
268 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
269 BOOST_CHECK(cs.earliest_tracked_block_id == bs_20->id);
270
271 ts = status.get_trx_state(std::get<1>(trx_pairs_20[0])->id());
272 BOOST_REQUIRE(ts);
273 BOOST_CHECK(ts->block_id == bs_20->id);
274 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
275 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
276 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
277
278 ts = status.get_trx_state(std::get<1>(trx_pairs_20[1])->id());
279 BOOST_REQUIRE(ts);
280 BOOST_CHECK(ts->block_id == bs_20->id);
281 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
282 BOOST_CHECK(fc::time_point_sec(ts->expiration) == (std::get<1>(trx_pairs_20[1])->expiration()));
283 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
284 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
285
286 ts = status.get_trx_state(std::get<1>(trx_pairs_20[2])->id());
287 BOOST_REQUIRE(ts);
288 BOOST_CHECK(ts->block_id == bs_20->id);
289 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
290 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
291 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
292
293 ts = status.get_trx_state(std::get<1>(trx_pairs_20[3])->id());
294 BOOST_REQUIRE(ts);
295 BOOST_CHECK(ts->block_id == bs_20->id);
296 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
297 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
298 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
299
300 ts = status.get_trx_state(std::get<1>(hold_pairs[0])->id());
301 BOOST_REQUIRE(ts);
302 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
303 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
304 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
305 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
306
307 ts = status.get_trx_state(std::get<1>(hold_pairs[1])->id());
308 BOOST_REQUIRE(ts);
309 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
310 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
311 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
312 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
313
314
315
316 // send block 21
317 const auto block_21_time = set_now("2022-04-04", "04:44:45.000");
318 trx_deque trx_pairs_21;
319 bn = 21;
320 const auto bs_21 = make_block_state(bn);
321 status.signal_block_start(bn);
323
324 add(trx_pairs_21, bs_21);
325 status.signal_accepted_block(bs_21);
326
327 cs = status.get_chain_state();
328 BOOST_CHECK(cs.head_id == bs_21->id);
329 BOOST_CHECK(cs.head_id == *std::get<0>(trx_pairs_21[0])->producer_block_id);
330 BOOST_CHECK(cs.head_block_timestamp == bs_21->block->timestamp);
331 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
332 BOOST_CHECK(cs.earliest_tracked_block_id == bs_20->id);
333
334 ts = status.get_trx_state(std::get<1>(trx_pairs_20[0])->id());
335 BOOST_REQUIRE(ts);
336 BOOST_CHECK(ts->block_id == bs_20->id);
337 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
338 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
339 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
340
341 ts = status.get_trx_state(std::get<1>(trx_pairs_20[1])->id());
342 BOOST_REQUIRE(ts);
343 BOOST_CHECK(ts->block_id == bs_20->id);
344 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
345 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
346 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
347
348 ts = status.get_trx_state(std::get<1>(trx_pairs_20[2])->id());
349 BOOST_REQUIRE(ts);
350 BOOST_CHECK(ts->block_id == bs_20->id);
351 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
352 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
353 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
354
355 ts = status.get_trx_state(std::get<1>(trx_pairs_20[3])->id());
356 BOOST_REQUIRE(ts);
357 BOOST_CHECK(ts->block_id == bs_20->id);
358 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
359 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
360 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
361
362 ts = status.get_trx_state(std::get<1>(hold_pairs[0])->id());
363 BOOST_REQUIRE(ts);
364 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
365 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
366 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
367 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
368
369 ts = status.get_trx_state(std::get<1>(hold_pairs[1])->id());
370 BOOST_REQUIRE(ts);
371 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
372 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
373 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
374 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
375
376 ts = status.get_trx_state(std::get<1>(trx_pairs_21[0])->id());
377 BOOST_REQUIRE(ts);
378 BOOST_CHECK(ts->block_id == bs_21->id);
379 BOOST_CHECK(ts->block_timestamp == bs_21->block->timestamp);
380 BOOST_CHECK_EQUAL(std::string(ts->received), block_21_time);
381 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
382
383
384
385 // send block 22
386 const auto block_22_time = set_now("2022-04-04", "04:44:45.500");
387 trx_deque trx_pairs_22;
388 bn = 22;
389
390 const auto bs_22 = make_block_state(bn);
391 status.signal_block_start(bn);
392
393 add(trx_pairs_22, bs_22);
394 status.signal_accepted_block(bs_22);
395
396 cs = status.get_chain_state();
397 BOOST_CHECK(cs.head_id == bs_22->id);
398 BOOST_CHECK(cs.head_id == *std::get<0>(trx_pairs_22[0])->producer_block_id);
399 BOOST_CHECK(cs.head_block_timestamp == bs_22->block->timestamp);
400 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
401 BOOST_CHECK(cs.earliest_tracked_block_id == bs_20->id);
402
403
404 ts = status.get_trx_state(std::get<1>(trx_pairs_20[0])->id());
405 BOOST_REQUIRE(ts);
406 BOOST_CHECK(ts->block_id == bs_20->id);
407 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
408 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
409 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
410
411 ts = status.get_trx_state(std::get<1>(trx_pairs_20[1])->id());
412 BOOST_REQUIRE(ts);
413 BOOST_CHECK(ts->block_id == bs_20->id);
414 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
415 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
416 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
417
418 ts = status.get_trx_state(std::get<1>(trx_pairs_20[2])->id());
419 BOOST_REQUIRE(ts);
420 BOOST_CHECK(ts->block_id == bs_20->id);
421 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
422 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
423 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
424
425 ts = status.get_trx_state(std::get<1>(trx_pairs_20[3])->id());
426 BOOST_REQUIRE(ts);
427 BOOST_CHECK(ts->block_id == bs_20->id);
428 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
429 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
430 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
431
432 ts = status.get_trx_state(std::get<1>(hold_pairs[0])->id());
433 BOOST_REQUIRE(ts);
434 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
435 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
436 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
437 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
438
439 ts = status.get_trx_state(std::get<1>(hold_pairs[1])->id());
440 BOOST_REQUIRE(ts);
441 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
442 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
443 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
444 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
445
446 ts = status.get_trx_state(std::get<1>(trx_pairs_21[0])->id());
447 BOOST_REQUIRE(ts);
448 BOOST_CHECK(ts->block_id == bs_21->id);
449 BOOST_CHECK(ts->block_timestamp == bs_21->block->timestamp);
450 BOOST_CHECK_EQUAL(std::string(ts->received), block_21_time);
451 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
452
453 ts = status.get_trx_state(std::get<1>(trx_pairs_22[0])->id());
454 BOOST_REQUIRE(ts);
455 BOOST_CHECK(ts->block_id == bs_22->id);
456 BOOST_CHECK(ts->block_timestamp == bs_22->block->timestamp);
457 BOOST_CHECK_EQUAL(std::string(ts->received), block_22_time);
458 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
459
460
461
462
463 // send block 22
464 const auto block_22_alt_time = set_now("2022-04-04", "04:44:46.000");
465 trx_deque trx_pairs_22_alt;
466 bn = 22;
467
468 const auto bs_22_alt = make_block_state(bn);
469 status.signal_block_start(bn);
470
471 add(trx_pairs_22_alt, bs_22_alt);
472 status.signal_accepted_block(bs_22_alt);
473
474 cs = status.get_chain_state();
475 BOOST_CHECK(cs.head_id == bs_22_alt->id);
476 BOOST_CHECK(cs.head_id == *std::get<0>(trx_pairs_22_alt[0])->producer_block_id);
477 BOOST_CHECK(cs.head_block_timestamp == bs_22_alt->block->timestamp);
478 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
479 BOOST_CHECK(cs.earliest_tracked_block_id == bs_20->id);
480
481
482 ts = status.get_trx_state(std::get<1>(trx_pairs_20[0])->id());
483 BOOST_REQUIRE(ts);
484 BOOST_CHECK(ts->block_id == bs_20->id);
485 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
486 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
487 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
488
489 ts = status.get_trx_state(std::get<1>(trx_pairs_20[1])->id());
490 BOOST_REQUIRE(ts);
491 BOOST_CHECK(ts->block_id == bs_20->id);
492 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
493 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
494 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
495
496 ts = status.get_trx_state(std::get<1>(trx_pairs_20[2])->id());
497 BOOST_REQUIRE(ts);
498 BOOST_CHECK(ts->block_id == bs_20->id);
499 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
500 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
501 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
502
503 ts = status.get_trx_state(std::get<1>(trx_pairs_20[3])->id());
504 BOOST_REQUIRE(ts);
505 BOOST_CHECK(ts->block_id == bs_20->id);
506 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
507 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
508 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
509
510 ts = status.get_trx_state(std::get<1>(hold_pairs[0])->id());
511 BOOST_REQUIRE(ts);
512 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
513 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
514 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
515 BOOST_CHECK_EQUAL(ts->status, "FAILED");
516
517 ts = status.get_trx_state(std::get<1>(hold_pairs[1])->id());
518 BOOST_REQUIRE(ts);
519 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
520 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
521 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
522 BOOST_CHECK_EQUAL(ts->status, "FAILED");
523
524 ts = status.get_trx_state(std::get<1>(trx_pairs_21[0])->id());
525 BOOST_REQUIRE(ts);
526 BOOST_CHECK(ts->block_id == bs_21->id);
527 BOOST_CHECK(ts->block_timestamp == bs_21->block->timestamp);
528 BOOST_CHECK_EQUAL(std::string(ts->received), block_21_time);
529 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
530
531 ts = status.get_trx_state(std::get<1>(trx_pairs_22[0])->id());
532 BOOST_REQUIRE(ts);
533 BOOST_CHECK(ts->block_id == bs_22->id);
534 BOOST_CHECK(ts->block_timestamp == bs_22->block->timestamp);
535 BOOST_CHECK_EQUAL(std::string(ts->received), block_22_time);
536 BOOST_CHECK_EQUAL(ts->status, "FORKED_OUT");
537
538 ts = status.get_trx_state(std::get<1>(trx_pairs_22_alt[0])->id());
539 BOOST_REQUIRE(ts);
540 BOOST_CHECK(ts->block_id == bs_22_alt->id);
541 BOOST_CHECK(ts->block_timestamp == bs_22_alt->block->timestamp);
542 BOOST_CHECK_EQUAL(std::string(ts->received), block_22_alt_time);
543 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
544
545
546
547 // send block 19 (forking out previous blocks.)
548 // Testing that code handles getting blocks before when it started
549 const auto block_19_time = set_now("2022-04-04", "04:44:47.000");
550 trx_deque trx_pairs_19;
551 bn = 19;
552
553 const auto bs_19 = make_block_state(bn);
554 status.signal_block_start(bn);
555
556 add(trx_pairs_19, bs_19);
557 status.signal_accepted_block(bs_19);
558
559 cs = status.get_chain_state();
560 BOOST_CHECK(cs.head_id == bs_19->id);
561 BOOST_CHECK(cs.head_id == *std::get<0>(trx_pairs_19[0])->producer_block_id);
562 BOOST_CHECK(cs.head_block_timestamp == bs_19->block->timestamp);
563 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
564 BOOST_CHECK(cs.earliest_tracked_block_id == bs_19->id);
565
566
567 ts = status.get_trx_state(std::get<1>(trx_pairs_20[0])->id());
568 BOOST_REQUIRE(ts);
569 BOOST_CHECK(ts->block_id == bs_20->id);
570 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
571 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
572 BOOST_CHECK_EQUAL(ts->status, "FAILED");
573
574 ts = status.get_trx_state(std::get<1>(trx_pairs_20[1])->id());
575 BOOST_REQUIRE(ts);
576 BOOST_CHECK(ts->block_id == bs_20->id);
577 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
578 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
579 BOOST_CHECK_EQUAL(ts->status, "FAILED");
580
581 ts = status.get_trx_state(std::get<1>(trx_pairs_20[2])->id());
582 BOOST_REQUIRE(ts);
583 BOOST_CHECK(ts->block_id == bs_20->id);
584 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
585 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
586 BOOST_CHECK_EQUAL(ts->status, "FAILED");
587
588 ts = status.get_trx_state(std::get<1>(trx_pairs_20[3])->id());
589 BOOST_REQUIRE(ts);
590 BOOST_CHECK(ts->block_id == bs_20->id);
591 BOOST_CHECK(ts->block_timestamp == bs_20->block->timestamp);
592 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
593 BOOST_CHECK_EQUAL(ts->status, "FAILED");
594
595 ts = status.get_trx_state(std::get<1>(hold_pairs[0])->id());
596 BOOST_REQUIRE(ts);
597 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
598 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
599 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
600 BOOST_CHECK_EQUAL(ts->status, "FAILED");
601
602 ts = status.get_trx_state(std::get<1>(hold_pairs[1])->id());
603 BOOST_REQUIRE(ts);
604 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
605 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
606 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
607 BOOST_CHECK_EQUAL(ts->status, "FAILED");
608
609 ts = status.get_trx_state(std::get<1>(trx_pairs_21[0])->id());
610 BOOST_REQUIRE(ts);
611 BOOST_CHECK(ts->block_id == bs_21->id);
612 BOOST_CHECK(ts->block_timestamp == bs_21->block->timestamp);
613 BOOST_CHECK_EQUAL(std::string(ts->received), block_21_time);
614 BOOST_CHECK_EQUAL(ts->status, "FAILED");
615
617 ts = status.get_trx_state(std::get<1>(trx_pairs_22[0])->id());
618 BOOST_REQUIRE(ts);
619 BOOST_CHECK(ts->block_id == bs_22->id);
620 BOOST_CHECK(ts->block_timestamp == bs_22->block->timestamp);
621 BOOST_CHECK_EQUAL(std::string(ts->received), block_22_time);
622 BOOST_CHECK_EQUAL(ts->status, "FAILED");
623
624 ts = status.get_trx_state(std::get<1>(trx_pairs_22_alt[0])->id());
625 BOOST_REQUIRE(ts);
626 BOOST_CHECK(ts->block_id == bs_22_alt->id);
627 BOOST_CHECK(ts->block_timestamp == bs_22_alt->block->timestamp);
628 BOOST_CHECK_EQUAL(std::string(ts->received), block_22_alt_time);
629 BOOST_CHECK_EQUAL(ts->status, "FORKED_OUT");
630
631 ts = status.get_trx_state(std::get<1>(trx_pairs_19[0])->id());
632 BOOST_REQUIRE(ts);
633 BOOST_CHECK(ts->block_id == bs_19->id);
634 BOOST_CHECK(ts->block_timestamp == bs_19->block->timestamp);
635 BOOST_CHECK_EQUAL(std::string(ts->received), block_19_time);
636 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
637
638
639
640 // send block 19 alternate
641 const auto block_19_alt_time = set_now("2022-04-04", "04:44:44.000");
642 trx_deque trx_pairs_19_alt;
643 bn = 19;
644 trx_pairs_19_alt.push_back(trx_pairs_19[0]);
645 trx_pairs_19_alt.push_back(trx_pairs_20[0]);
646 trx_pairs_19_alt.push_back(trx_pairs_20[1]);
647 trx_pairs_19_alt.push_back(trx_pairs_20[2]);
648 trx_pairs_19_alt.push_back(trx_pairs_20[3]);
649 trx_pairs_19_alt.push_back(hold_pairs[0]);
650
651 const auto bs_19_alt = make_block_state(bn);
652 // const auto bs_19_alt = make_block_state(make_block_id(bn), std::vector<chain::packed_transaction_ptr>{});
653 status.signal_block_start(bn);
654
655 for (const auto& trx_tuple : trx_pairs_19_alt) {
656 const auto& trace = std::get<0>(trx_tuple);
657 const auto& txn = std::get<1>(trx_tuple);
658
659 trace->producer_block_id = bs_19_alt->id;
660 trace->block_time = bs_19_alt->block->timestamp;
661
662 status.signal_applied_transaction(trace, txn);
663 }
664
665 status.signal_accepted_block(bs_19_alt);
666
667 cs = status.get_chain_state();
668 BOOST_CHECK(cs.head_id == bs_19_alt->id);
669 BOOST_CHECK(cs.head_id == *std::get<0>(trx_pairs_19[0])->producer_block_id);
670 BOOST_CHECK(cs.head_block_timestamp == bs_19_alt->block->timestamp);
671 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
672 BOOST_CHECK(cs.earliest_tracked_block_id == bs_19_alt->id);
673
674
675 ts = status.get_trx_state(std::get<1>(trx_pairs_20[0])->id());
676 BOOST_REQUIRE(ts);
677 BOOST_CHECK(ts->block_id == bs_19_alt->id);
678 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
679 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
680 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
681
682 ts = status.get_trx_state(std::get<1>(trx_pairs_20[1])->id());
683 BOOST_REQUIRE(ts);
684 BOOST_CHECK(ts->block_id == bs_19_alt->id);
685 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
686 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
687 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
688
689 ts = status.get_trx_state(std::get<1>(trx_pairs_20[2])->id());
690 BOOST_REQUIRE(ts);
691 BOOST_CHECK(ts->block_id == bs_19_alt->id);
692 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
693 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
694 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
695
696 ts = status.get_trx_state(std::get<1>(trx_pairs_20[3])->id());
697 BOOST_REQUIRE(ts);
698 BOOST_CHECK(ts->block_id == bs_19_alt->id);
699 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
700 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
701 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
702
703 ts = status.get_trx_state(std::get<1>(hold_pairs[0])->id());
704 BOOST_REQUIRE(ts);
705 BOOST_CHECK(ts->block_id == bs_19_alt->id);
706 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
707 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
708 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
709
710 ts = status.get_trx_state(std::get<1>(hold_pairs[1])->id());
711 BOOST_REQUIRE(ts);
712 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
713 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
714 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
715 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
716
717 ts = status.get_trx_state(std::get<1>(trx_pairs_21[0])->id());
718 BOOST_REQUIRE(ts);
719 BOOST_CHECK(ts->block_id == bs_21->id);
720 BOOST_CHECK(ts->block_timestamp == bs_21->block->timestamp);
721 BOOST_CHECK_EQUAL(std::string(ts->received), block_21_time);
722 BOOST_CHECK_EQUAL(ts->status, "FORKED_OUT");
723
725 ts = status.get_trx_state(std::get<1>(trx_pairs_22[0])->id());
726 BOOST_REQUIRE(ts);
727 BOOST_CHECK(ts->block_id == bs_22->id);
728 BOOST_CHECK(ts->block_timestamp == bs_22->block->timestamp);
729 BOOST_CHECK_EQUAL(std::string(ts->received), block_22_time);
730 BOOST_CHECK_EQUAL(ts->status, "FORKED_OUT");
731
732 ts = status.get_trx_state(std::get<1>(trx_pairs_22_alt[0])->id());
733 BOOST_REQUIRE(ts);
734 BOOST_CHECK(ts->block_id == bs_22_alt->id);
735 BOOST_CHECK(ts->block_timestamp == bs_22_alt->block->timestamp);
736 BOOST_CHECK_EQUAL(std::string(ts->received), block_22_alt_time);
737 BOOST_CHECK_EQUAL(ts->status, "FORKED_OUT");
738
739 ts = status.get_trx_state(std::get<1>(trx_pairs_19[0])->id());
740 BOOST_REQUIRE(ts);
741 BOOST_CHECK(ts->block_id == bs_19_alt->id);
742 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
743 BOOST_CHECK_EQUAL(std::string(ts->received), block_19_time);
744 BOOST_CHECK_EQUAL(ts->status, "IN_BLOCK");
745
746
747 // look for unknown transaction
748 auto trx = make_unique_trx(fc::seconds(2));
749
750 ts = status.get_trx_state(trx->id());
751 BOOST_REQUIRE(!ts);
752
753 // irreversible
754 status.signal_irreversible_block(bs_19_alt);
755
756 cs = status.get_chain_state();
757 BOOST_CHECK(cs.head_id == bs_19_alt->id);
758 BOOST_CHECK(cs.irr_id == bs_19_alt->id);
759 BOOST_CHECK(cs.irr_block_timestamp == bs_19_alt->block->timestamp);
760 BOOST_CHECK(cs.earliest_tracked_block_id == bs_19_alt->id);
761
762
763 ts = status.get_trx_state(std::get<1>(trx_pairs_20[0])->id());
764 BOOST_REQUIRE(ts);
765 BOOST_CHECK(ts->block_id == bs_19_alt->id);
766 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
767 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
768 BOOST_CHECK_EQUAL(ts->status, "IRREVERSIBLE");
769
770 ts = status.get_trx_state(std::get<1>(trx_pairs_20[1])->id());
771 BOOST_REQUIRE(ts);
772 BOOST_CHECK(ts->block_id == bs_19_alt->id);
773 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
774 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
775 BOOST_CHECK_EQUAL(ts->status, "IRREVERSIBLE");
776
777 ts = status.get_trx_state(std::get<1>(trx_pairs_20[2])->id());
778 BOOST_REQUIRE(ts);
779 BOOST_CHECK(ts->block_id == bs_19_alt->id);
780 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
781 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
782 BOOST_CHECK_EQUAL(ts->status, "IRREVERSIBLE");
783
784 ts = status.get_trx_state(std::get<1>(trx_pairs_20[3])->id());
785 BOOST_REQUIRE(ts);
786 BOOST_CHECK(ts->block_id == bs_19_alt->id);
787 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
788 BOOST_CHECK_EQUAL(std::string(ts->received), block_20_time);
789 BOOST_CHECK_EQUAL(ts->status, "IRREVERSIBLE");
790
791 ts = status.get_trx_state(std::get<1>(hold_pairs[0])->id());
792 BOOST_REQUIRE(ts);
793 BOOST_CHECK(ts->block_id == bs_19_alt->id);
794 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
795 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
796 BOOST_CHECK_EQUAL(ts->status, "IRREVERSIBLE");
797
798 ts = status.get_trx_state(std::get<1>(hold_pairs[1])->id());
799 BOOST_REQUIRE(ts);
800 BOOST_CHECK(ts->block_id == sysio::chain::block_id_type{});
801 BOOST_CHECK(ts->block_timestamp == sysio::chain::block_timestamp_type{});
802 BOOST_CHECK_EQUAL(std::string(ts->received), pre_block_20_time);
803 BOOST_CHECK_EQUAL(ts->status, "LOCALLY_APPLIED");
804
805 ts = status.get_trx_state(std::get<1>(trx_pairs_21[0])->id());
806 BOOST_REQUIRE(ts);
807 BOOST_CHECK(ts->block_id == bs_21->id);
808 BOOST_CHECK(ts->block_timestamp == bs_21->block->timestamp);
809 BOOST_CHECK_EQUAL(std::string(ts->received), block_21_time);
810 BOOST_CHECK_EQUAL(ts->status, "FORKED_OUT");
811
813 ts = status.get_trx_state(std::get<1>(trx_pairs_22[0])->id());
814 BOOST_REQUIRE(ts);
815 BOOST_CHECK(ts->block_id == bs_22->id);
816 BOOST_CHECK(ts->block_timestamp == bs_22->block->timestamp);
817 BOOST_CHECK_EQUAL(std::string(ts->received), block_22_time);
818 BOOST_CHECK_EQUAL(ts->status, "FORKED_OUT");
819
820 ts = status.get_trx_state(std::get<1>(trx_pairs_22_alt[0])->id());
821 BOOST_REQUIRE(ts);
822 BOOST_CHECK(ts->block_id == bs_22_alt->id);
823 BOOST_CHECK(ts->block_timestamp == bs_22_alt->block->timestamp);
824 BOOST_CHECK_EQUAL(std::string(ts->received), block_22_alt_time);
825 BOOST_CHECK_EQUAL(ts->status, "FORKED_OUT");
826
827 ts = status.get_trx_state(std::get<1>(trx_pairs_19[0])->id());
828 BOOST_REQUIRE(ts);
829 BOOST_CHECK(ts->block_id == bs_19_alt->id);
830 BOOST_CHECK(ts->block_timestamp == bs_19_alt->block->timestamp);
831 BOOST_CHECK_EQUAL(std::string(ts->received), block_19_time);
832 BOOST_CHECK_EQUAL(ts->status, "IRREVERSIBLE");
833
logger & set_log_level(log_level e)
Definition logger.cpp:100
static logger get(const fc::string &name=DEFAULT_LOGGER)
Definition logger.cpp:88
#define DEFAULT_LOGGER
Definition logger.hpp:7
Definition bn.h:56
std::shared_ptr< block_state > block_state_ptr
auto make_block_state(chain::block_id_type previous, uint32_t height, uint32_t slot, chain::name producer, std::vector< chain::packed_transaction > trxs)
int add(int a, int b)
unsigned int uint32_t
Definition stdint.h:126
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( trx_finality_status_storage_reduction )

Definition at line 947 of file test_trx_finality_status_processing.cpp.

947 { try {
948 set_now("2022-04-04", "04:44:44.450");
949 fc::microseconds max_success_duration = fc::seconds(25);
950 fc::microseconds max_failure_duration = fc::seconds(45);
951 const uint64_t max_storage = 10'000;
952 trx_finality_status_processing status(max_storage, max_success_duration, max_failure_duration);
953
954 // auto verify_trx = [&status](trx_deque& trx_pairs, const sysio::chain::block_state_ptr& bs) {
955 // const auto id = bs ? bs->id : sysio::chain::transaction_id_type{};
956 // for (const auto& trx_pair : trx_pairs) {
957 // auto ts = status.get_trx_state(std::get<1>(trx_pair)->id());
958 // BOOST_REQUIRE(ts);
959 // BOOST_CHECK(ts->block_id == id);
960 // }
961 // };
962
963 block_frame b_01(status, "04:44:00.500", 1);
964 b_01.send_spec_block();
965 b_01.verify_spec_block();
966
967 b_01.send_block();
968 b_01.verify_block();
969
970 const auto block_and_speculative_size = status.get_storage_memory_size();
971 // test expects to not hit the storage limitation till the 12th block
972 BOOST_REQUIRE(max_storage / 11 > block_and_speculative_size);
973 BOOST_REQUIRE(max_storage / 12 < block_and_speculative_size);
974
975
976 block_frame b_02(status, "04:44:01.500");
977 b_02.send_spec_block();
978 b_02.verify_spec_block();
979
980 b_02.send_block();
981 b_02.verify_block();
982
983
984 block_frame b_03(status, "04:44:02.500");
985 b_03.send_spec_block();
986 b_03.verify_spec_block();
987
988 b_03.send_block();
989 b_03.verify_block();
990
991
992 block_frame b_04(status, "04:44:03.500");
993 b_04.send_spec_block();
994 b_04.verify_spec_block();
995
996 b_04.send_block();
997 b_04.verify_block();
998
999
1000 block_frame b_05(status, "04:44:04.500");
1001 b_05.send_spec_block();
1002 b_05.verify_spec_block();
1003
1004 b_05.send_block();
1005 b_05.verify_block();
1006
1007
1008 block_frame b_06(status, "04:44:05.500");
1009 b_06.send_spec_block();
1010 b_06.verify_spec_block();
1011
1012 b_06.send_block();
1013 b_06.verify_block();
1014
1015
1016 block_frame b_07(status, "04:44:06.500");
1017 b_07.send_spec_block();
1018 b_07.verify_spec_block();
1019
1020 b_07.send_block();
1021 b_07.verify_block();
1022
1023
1024 block_frame b_08(status, "04:44:07.500");
1025 b_08.send_spec_block();
1026 b_08.verify_spec_block();
1027
1028 b_08.send_block();
1029 b_08.verify_block();
1030
1031
1032 block_frame b_09(status, "04:44:08.500");
1033 b_09.send_spec_block();
1034 b_09.verify_spec_block();
1035
1036 b_09.send_block();
1037 b_09.verify_block();
1038
1039
1040 block_frame b_10(status, "04:44:09.500");
1041 b_10.send_spec_block();
1042 b_10.verify_spec_block();
1043
1044 b_10.send_block();
1045 b_10.verify_block();
1046
1047
1048 block_frame b_11(status, "04:44:10.500");
1049 b_11.send_spec_block();
1050 b_11.verify_spec_block();
1051
1052 b_11.send_block();
1053 b_11.verify_block();
1054
1055
1056
1057 auto cs = status.get_chain_state();
1058 BOOST_CHECK(cs.head_id == b_11.bs->id);
1059 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
1060 BOOST_CHECK(cs.earliest_tracked_block_id == b_01.bs->id);
1061
1062 // Test expects the next block range to exceed max_storage. Need to adjust
1063 // this test if this fails.
1064 BOOST_REQUIRE(status.get_storage_memory_size() + block_and_speculative_size > max_storage);
1065
1066
1067 block_frame b_12(status, "04:44:11.500");
1068 b_12.send_spec_block();
1069 b_12.verify_spec_block();
1070
1071 b_12.send_block();
1072 b_12.verify_block();
1073
1074 cs = status.get_chain_state();
1075 BOOST_CHECK(cs.head_id == b_12.bs->id);
1076 BOOST_CHECK(cs.head_block_timestamp == b_12.bs->block->timestamp);
1077 BOOST_CHECK(cs.irr_id == sysio::chain::block_id_type{});
1078 BOOST_CHECK(cs.irr_block_timestamp == sysio::chain::block_timestamp_type{});
1079 BOOST_CHECK(cs.earliest_tracked_block_id == b_03.bs->id);
1080
1081
1082 b_01.verify_spec_block_not_there();
1083 b_01.verify_block_not_there();
1084
1085 b_02.verify_spec_block_not_there();
1086 b_02.verify_block_not_there();
1087
1088 b_03.verify_spec_block();
1089 b_03.verify_block();
1090
1091 b_04.verify_spec_block();
1092 b_04.verify_block();
1093
1094 b_05.verify_spec_block();
1095 b_05.verify_block();
1096
1097 b_06.verify_spec_block();
1098 b_06.verify_block();
1099
1100 b_07.verify_spec_block();
1101 b_07.verify_block();
1102
1103 b_08.verify_spec_block();
1104 b_08.verify_block();
1105
1106 b_09.verify_spec_block();
1107 b_09.verify_block();
1108
1109 b_10.verify_spec_block();
1110 b_10.verify_block();
1111
1112 b_11.verify_spec_block();
1113 b_11.verify_block();
1114
1115 b_12.verify_spec_block();
1116 b_12.verify_block();
1117
Here is the call graph for this function: