200 boost::filesystem::path temp = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
206 std::optional<controller> chain;
213 const auto& genesis_chain_id = gs.compute_chain_id();
215 chain.emplace(
chain_config, std::move( pfs ), genesis_chain_id );
216 chain->add_indices();
220 auto pnow = boost::posix_time::time_from_string(
"2022-04-04 4:44:44.000");
224 std::thread app_thread( [&]() {
228 size_t max_mem_usage_size = 5ul*1024*1024*1024;
230 boost::posix_time::seconds pretry_interval = boost::posix_time::seconds(10);
231 BOOST_REQUIRE(retry_interval.
count() == pretry_interval.total_microseconds());
236 blocking_queue<std::pair<fc::exception_ptr, packed_transaction_ptr>> transactions_acked;
237 plugin_interface::compat::channels::transaction_ack::channel_type::handle incoming_transaction_ack_subscription =
239 [&transactions_acked](
const std::pair<fc::exception_ptr, packed_transaction_ptr>& t){
240 transactions_acked.push( t );
250 auto lib = std::optional<uint16_t>{};
251 auto trx_1 = make_unique_trx(chain->get_chain_id(),
fc::seconds(2), 1);
252 bool trx_1_expired =
false;
254 BOOST_REQUIRE( std::holds_alternative<fc::exception_ptr>(result) );
255 BOOST_CHECK_EQUAL( std::get<fc::exception_ptr>(result)->code(), expired_tx_exception::code_value );
256 trx_1_expired =
true;
258 auto trx_2 = make_unique_trx(chain->get_chain_id(),
fc::seconds(4), 2);
259 bool trx_2_expired =
false;
261 BOOST_REQUIRE( std::holds_alternative<fc::exception_ptr>(result) );
262 BOOST_CHECK_EQUAL( std::get<fc::exception_ptr>(result)->code(), expired_tx_exception::code_value );
263 trx_2_expired =
true;
266 auto bsp1 = make_block_state(1, {});
270 BOOST_CHECK(!trx_1_expired);
271 BOOST_CHECK(!trx_2_expired);
273 pnow += boost::posix_time::seconds(3);
276 auto bsp2 = make_block_state(2, {});
280 BOOST_CHECK(trx_1_expired);
281 BOOST_CHECK(!trx_2_expired);
283 pnow += boost::posix_time::seconds(2);
286 auto bsp3 = make_block_state(3, {});
290 BOOST_CHECK(trx_1_expired);
291 BOOST_CHECK(trx_2_expired);
292 BOOST_CHECK_EQUAL(0, trx_retry.
size());
297 auto trx_3 = make_unique_trx(chain->get_chain_id(),
fc::seconds(30), 3);
298 bool trx_3_expired =
false;
300 BOOST_REQUIRE( std::holds_alternative<fc::exception_ptr>(result) );
301 BOOST_CHECK_EQUAL( std::get<fc::exception_ptr>(result)->code(), expired_tx_exception::code_value );
302 trx_3_expired =
true;
305 pnow += boost::posix_time::seconds(1);
307 auto trx_4 = make_unique_trx(chain->get_chain_id(),
fc::seconds(30), 4);
308 bool trx_4_expired =
false;
310 BOOST_REQUIRE( std::holds_alternative<fc::exception_ptr>(result) );
311 BOOST_CHECK_EQUAL( std::get<fc::exception_ptr>(result)->code(), expired_tx_exception::code_value );
312 trx_4_expired =
true;
315 pnow += (pretry_interval - boost::posix_time::seconds(1));
318 auto bsp4 = make_block_state(4, {});
321 BOOST_CHECK( get_id(transactions_acked.pop().second) == 3 );
322 BOOST_CHECK_EQUAL( 0, transactions_acked.size() );
324 pnow += boost::posix_time::seconds(1);
327 auto bsp5 = make_block_state(5, {});
330 BOOST_CHECK( get_id(transactions_acked.pop().second) == 4 );
331 BOOST_CHECK_EQUAL( 0, transactions_acked.size() );
332 BOOST_CHECK(!trx_3_expired);
333 BOOST_CHECK(!trx_4_expired);
335 pnow += boost::posix_time::seconds(30);
337 auto bsp6 = make_block_state(6, {});
343 BOOST_CHECK(trx_3_expired);
344 BOOST_CHECK(trx_4_expired);
345 BOOST_CHECK_EQUAL(0, trx_retry.
size());
350 auto trx_5 = make_unique_trx(chain->get_chain_id(),
fc::seconds(30), 5);
351 bool trx_5_variant =
false;
353 BOOST_REQUIRE( std::holds_alternative<std::unique_ptr<fc::variant>>(result) );
354 BOOST_CHECK( !!std::get<std::unique_ptr<fc::variant>>(result) );
355 trx_5_variant =
true;
358 pnow += boost::posix_time::seconds(1);
360 auto trx_6 = make_unique_trx(chain->get_chain_id(),
fc::seconds(30), 6);
361 bool trx_6_variant =
false;
363 BOOST_REQUIRE( std::holds_alternative<std::unique_ptr<fc::variant>>(result) );
364 BOOST_CHECK( !!std::get<std::unique_ptr<fc::variant>>(result) );
365 trx_6_variant =
true;
368 auto bsp7 = make_block_state(7, {});
371 BOOST_CHECK(!trx_5_variant);
372 BOOST_CHECK(!trx_6_variant);
374 pnow += boost::posix_time::seconds(1);
377 auto trace_5 = make_transaction_trace( trx_5, 8);
378 auto trace_6 = make_transaction_trace( trx_6, 8);
381 auto bsp8 = make_block_state(8, {trx_5, trx_6});
383 BOOST_CHECK(!trx_5_variant);
384 BOOST_CHECK(!trx_6_variant);
386 pnow += boost::posix_time::seconds(1);
388 auto bsp9 = make_block_state(9, {});
391 BOOST_CHECK(!trx_5_variant);
392 BOOST_CHECK(!trx_6_variant);
393 pnow += boost::posix_time::seconds(1);
395 auto bsp10 = make_block_state(10, {});
398 BOOST_CHECK(!trx_5_variant);
399 BOOST_CHECK(trx_6_variant);
401 pnow += boost::posix_time::seconds(1);
403 auto bsp11 = make_block_state(11, {});
406 BOOST_CHECK(!trx_5_variant);
407 BOOST_CHECK(trx_6_variant);
409 BOOST_CHECK(!trx_5_variant);
410 BOOST_CHECK(trx_6_variant);
412 BOOST_CHECK(trx_5_variant);
413 BOOST_CHECK(trx_6_variant);
414 BOOST_CHECK_EQUAL(0, trx_retry.
size());
419 auto trx_7 = make_unique_trx(chain->get_chain_id(),
fc::seconds(30), 7);
420 bool trx_7_variant =
false;
422 BOOST_REQUIRE( std::holds_alternative<std::unique_ptr<fc::variant>>(result) );
423 BOOST_CHECK( !!std::get<std::unique_ptr<fc::variant>>(result) );
424 trx_7_variant =
true;
427 pnow += boost::posix_time::seconds(1);
429 auto trx_8 = make_unique_trx(chain->get_chain_id(),
fc::seconds(30), 8);
430 bool trx_8_variant =
false;
432 BOOST_REQUIRE( std::holds_alternative<std::unique_ptr<fc::variant>>(result) );
433 BOOST_CHECK( !!std::get<std::unique_ptr<fc::variant>>(result) );
434 trx_8_variant =
true;
437 auto trx_9 = make_unique_trx(chain->get_chain_id(),
fc::seconds(30), 9);
438 bool trx_9_expired =
false;
440 BOOST_REQUIRE( std::holds_alternative<fc::exception_ptr>(result) );
441 BOOST_CHECK_EQUAL( std::get<fc::exception_ptr>(result)->code(), expired_tx_exception::code_value );
442 trx_9_expired =
true;
446 auto bsp12 = make_block_state(12, {});
449 BOOST_CHECK(!trx_7_variant);
450 BOOST_CHECK(!trx_8_variant);
451 BOOST_CHECK(!trx_9_expired);
453 pnow += boost::posix_time::seconds(1);
456 auto trace_7 = make_transaction_trace( trx_7, 13);
457 auto trace_8 = make_transaction_trace( trx_8, 13);
458 auto trace_9 = make_transaction_trace( trx_9, 13);
462 auto bsp13 = make_block_state(13, {trx_7, trx_8, trx_9});
464 BOOST_CHECK(!trx_7_variant);
465 BOOST_CHECK(!trx_8_variant);
466 BOOST_CHECK(!trx_9_expired);
468 pnow += boost::posix_time::seconds(1);
470 auto bsp14 = make_block_state(14, {});
473 BOOST_CHECK(!trx_7_variant);
474 BOOST_CHECK(!trx_8_variant);
475 BOOST_CHECK(!trx_9_expired);
476 pnow += boost::posix_time::seconds(1);
478 auto bsp15 = make_block_state(15, {});
481 BOOST_CHECK(!trx_7_variant);
482 BOOST_CHECK(!trx_8_variant);
483 BOOST_CHECK(!trx_9_expired);
485 pnow += boost::posix_time::seconds(1);
489 BOOST_CHECK_EQUAL(3, trx_retry.
size());
491 auto bsp13b = make_block_state(13, {});
494 pnow += boost::posix_time::seconds(1);
498 auto bsp14b = make_block_state(14, {});
502 auto trace_7b = make_transaction_trace( trx_7, 15);
503 auto trace_8b = make_transaction_trace( trx_8, 15);
506 auto bsp15b = make_block_state(15, {trx_7, trx_8});
509 pnow += boost::posix_time::seconds(1);
511 auto bsp16 = make_block_state(16, {});
514 BOOST_CHECK(!trx_7_variant);
515 BOOST_CHECK(!trx_8_variant);
516 BOOST_CHECK(!trx_9_expired);
517 pnow += boost::posix_time::seconds(1);
519 auto bsp17 = make_block_state(17, {});
522 BOOST_CHECK(!trx_7_variant);
523 BOOST_CHECK(!trx_8_variant);
524 BOOST_CHECK(!trx_9_expired);
525 pnow += boost::posix_time::seconds(1);
527 auto bsp18 = make_block_state(18, {});
530 BOOST_CHECK(!trx_7_variant);
531 BOOST_CHECK(trx_8_variant);
532 BOOST_CHECK(!trx_9_expired);
539 BOOST_CHECK(!trx_7_variant);
540 BOOST_CHECK(trx_8_variant);
541 BOOST_CHECK(!trx_9_expired);
543 BOOST_CHECK(trx_7_variant);
544 BOOST_CHECK(trx_8_variant);
545 BOOST_CHECK(!trx_9_expired);
547 pnow += boost::posix_time::seconds(21);
549 auto bsp19 = make_block_state(19, {});
557 BOOST_CHECK(trx_7_variant);
558 BOOST_CHECK(trx_8_variant);
559 BOOST_CHECK(!trx_9_expired);
560 pnow += boost::posix_time::seconds(1);
562 auto bsp20 = make_block_state(20, {});
566 BOOST_CHECK(trx_7_variant);
567 BOOST_CHECK(trx_8_variant);
568 BOOST_CHECK(!trx_9_expired);
570 BOOST_CHECK(trx_7_variant);
571 BOOST_CHECK(trx_8_variant);
572 BOOST_CHECK(trx_9_expired);
573 BOOST_CHECK_EQUAL(0, trx_retry.
size());
578 auto trx_10 = make_unique_trx(chain->get_chain_id(),
fc::seconds(30), 10);
579 bool trx_10_variant =
false;
581 BOOST_REQUIRE( std::holds_alternative<std::unique_ptr<fc::variant>>(result) );
582 BOOST_CHECK( !!std::get<std::unique_ptr<fc::variant>>(result) );
583 trx_10_variant =
true;
585 auto trx_11 = make_unique_trx(chain->get_chain_id(),
fc::seconds(30), 11);
586 bool trx_11_variant =
false;
588 BOOST_REQUIRE( std::holds_alternative<std::unique_ptr<fc::variant>>(result) );
589 BOOST_CHECK( !!std::get<std::unique_ptr<fc::variant>>(result) );
590 trx_11_variant =
true;
594 auto trace_10 = make_transaction_trace( trx_10, 21);
595 auto trace_11 = make_transaction_trace( trx_11, 21);
598 auto bsp21 = make_block_state(21, {trx_10, trx_11});
600 BOOST_CHECK(trx_10_variant);
601 BOOST_CHECK(!trx_11_variant);
602 pnow += boost::posix_time::seconds(1);
604 auto bsp22 = make_block_state(22, {});
607 BOOST_CHECK(trx_10_variant);
608 BOOST_CHECK(trx_11_variant);
609 BOOST_CHECK_EQUAL(0, trx_retry.
size());
617 boost::filesystem::remove_all( temp );
620 boost::filesystem::remove_all( temp );