Skip to content

Commit 4aca6e3

Browse files
authoredJun 16, 2022
Merge pull request AntelopeIO#404 from eosnetworkfoundation/main_post_3_1
Merge Main post 3 1 into Main
2 parents 3c6a5c9 + a1a7d0e commit 4aca6e3

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed
 

‎libraries/testing/include/eosio/testing/tester.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,8 @@ namespace eosio { namespace testing {
517517
try {
518518
if( num_blocks_to_producer_before_shutdown > 0 )
519519
produce_blocks( num_blocks_to_producer_before_shutdown );
520-
if (!skip_validate)
521-
BOOST_REQUIRE_EQUAL( validate(), true );
520+
if (!skip_validate && std::uncaught_exceptions() == 0)
521+
BOOST_CHECK_EQUAL( validate(), true );
522522
} catch( const fc::exception& e ) {
523523
wdump((e.to_detail_string()));
524524
}

‎plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ struct txn_test_gen_plugin_impl {
102102
name newaccountA;
103103
name newaccountB;
104104
name newaccountT;
105+
fc::microseconds trx_expiration{3600};
106+
bool stop_on_trx_failed{true};
105107

106108
void push_next_transaction(const std::shared_ptr<std::vector<signed_transaction>>& trxs, const std::function<void(const fc::exception_ptr&)>& next ) {
107109
chain_plugin& cp = app().get_plugin<chain_plugin>();
@@ -333,7 +335,7 @@ struct txn_test_gen_plugin_impl {
333335
send_transaction([this](const fc::exception_ptr& e){
334336
if (e) {
335337
elog("pushing transaction failed: ${e}", ("e", e->to_detail_string()));
336-
if(running)
338+
if(running && stop_on_trx_failed)
337339
stop_generation();
338340
}
339341
}, nonce_prefix++);
@@ -376,7 +378,7 @@ struct txn_test_gen_plugin_impl {
376378
trx.actions.push_back(act_a_to_b);
377379
trx.context_free_actions.emplace_back(action({}, config::null_account_name, name("nonce"), fc::raw::pack( std::to_string(nonce_prefix)+std::to_string(nonce++) )));
378380
trx.set_reference_block(reference_block_id);
379-
trx.expiration = cc.head_block_time() + fc::seconds(30);
381+
trx.expiration = cc.head_block_time() + trx_expiration;
380382
trx.max_net_usage_words = 100;
381383
trx.sign(a_priv_key, chainid);
382384
trxs.emplace_back(std::move(trx));
@@ -387,7 +389,7 @@ struct txn_test_gen_plugin_impl {
387389
trx.actions.push_back(act_b_to_a);
388390
trx.context_free_actions.emplace_back(action({}, config::null_account_name, name("nonce"), fc::raw::pack( std::to_string(nonce_prefix)+std::to_string(nonce++) )));
389391
trx.set_reference_block(reference_block_id);
390-
trx.expiration = cc.head_block_time() + fc::seconds(30);
392+
trx.expiration = cc.head_block_time() + trx_expiration;
391393
trx.max_net_usage_words = 100;
392394
trx.sign(b_priv_key, chainid);
393395
trxs.emplace_back(std::move(trx));
@@ -442,6 +444,8 @@ void txn_test_gen_plugin::set_program_options(options_description&, options_desc
442444
("txn-reference-block-lag", bpo::value<int32_t>()->default_value(0), "Lag in number of blocks from the head block when selecting the reference block for transactions (-1 means Last Irreversible Block)")
443445
("txn-test-gen-threads", bpo::value<uint16_t>()->default_value(2), "Number of worker threads in txn_test_gen thread pool")
444446
("txn-test-gen-account-prefix", bpo::value<string>()->default_value("txn.test."), "Prefix to use for accounts generated and used by this plugin")
447+
("txn-test-gen-expiration-seconds", bpo::value<uint16_t>()->default_value(30), "expiration in seconds for transactions generated by this plugin")
448+
("txn-test-gen-stop-on-push-failed", bpo::value<bool>()->default_value(true), "stop generation when pushed transaction failed")
445449
;
446450
}
447451

@@ -454,6 +458,11 @@ void txn_test_gen_plugin::plugin_initialize(const variables_map& options) {
454458
my->newaccountA = eosio::chain::name(thread_pool_account_prefix + "a");
455459
my->newaccountB = eosio::chain::name(thread_pool_account_prefix + "b");
456460
my->newaccountT = eosio::chain::name(thread_pool_account_prefix + "t");
461+
my->trx_expiration = fc::seconds(options.at("txn-test-gen-expiration-seconds").as<uint16_t>());
462+
EOS_ASSERT(my->trx_expiration < fc::seconds(3600), chain::plugin_config_exception,
463+
"txn-test-gen-expiration-seconds must be smaller than 3600");
464+
my->stop_on_trx_failed = options.at("txn-test-gen-stop-on-push-failed").as<bool>();
465+
457466
EOS_ASSERT( my->thread_pool_size > 0, chain::plugin_config_exception,
458467
"txn-test-gen-threads ${num} must be greater than 0", ("num", my->thread_pool_size) );
459468
} FC_LOG_AND_RETHROW()

‎unittests/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
void translate_fc_exception(const fc::exception &e) {
1414
std::cerr << "\033[33m" << e.to_detail_string() << "\033[0m" << std::endl;
15-
BOOST_TEST_FAIL("Caught Unexpected Exception");
15+
throw std::runtime_error("Caught Unexpected Exception");
1616
}
1717

1818
static bool is_verbose = false;

0 commit comments

Comments
 (0)