Skip to content

Commit a972330

Browse files
Changed validating_tester to allow setting trusted_producers and to manually produce blocks on the main chain and then manually pass the block to the validating_node. GH #5268
1 parent 0754e85 commit a972330

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,17 @@ namespace eosio { namespace testing {
308308
try {
309309
if( num_blocks_to_producer_before_shutdown > 0 )
310310
produce_blocks( num_blocks_to_producer_before_shutdown );
311-
BOOST_REQUIRE_EQUAL( validate(), true );
311+
if (!skip_validate)
312+
BOOST_REQUIRE_EQUAL( validate(), true );
312313
} catch( const fc::exception& e ) {
313314
wdump((e.to_detail_string()));
314315
}
315316
}
316317
controller::config vcfg;
317318

318-
validating_tester() {
319+
static controller::config default_config() {
320+
fc::temp_directory tempdir;
321+
controller::config vcfg;
319322
vcfg.blocks_dir = tempdir.path() / std::string("v_").append(config::default_blocks_dir_name);
320323
vcfg.state_dir = tempdir.path() / std::string("v_").append(config::default_state_dir_name);
321324
vcfg.state_size = 1024*1024*8;
@@ -333,7 +336,13 @@ namespace eosio { namespace testing {
333336
else if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wavm"))
334337
vcfg.wasm_runtime = chain::wasm_interface::vm_type::wavm;
335338
}
339+
return vcfg;
340+
}
341+
342+
validating_tester(const flat_set<account_name>& trusted_producers = flat_set<account_name>()) {
343+
vcfg = default_config();
336344

345+
vcfg.trusted_producers = trusted_producers;
337346

338347
validating_node = std::make_unique<controller>(vcfg);
339348
validating_node->startup();
@@ -362,6 +371,14 @@ namespace eosio { namespace testing {
362371
return sb;
363372
}
364373

374+
signed_block_ptr produce_block_no_validation( fc::microseconds skip_time = fc::milliseconds(config::block_interval_ms), uint32_t skip_flag = 0 /*skip_missed_block_penalty*/ ) {
375+
return _produce_block(skip_time, false, skip_flag | 2);
376+
}
377+
378+
void validate_push_block(const signed_block_ptr& sb) {
379+
validating_node->push_block( sb );
380+
}
381+
365382
signed_block_ptr produce_empty_block( fc::microseconds skip_time = fc::milliseconds(config::block_interval_ms), uint32_t skip_flag = 0 /*skip_missed_block_penalty*/ )override {
366383
control->abort_block();
367384
auto sb = _produce_block(skip_time, true, skip_flag | 2);
@@ -393,6 +410,7 @@ namespace eosio { namespace testing {
393410

394411
unique_ptr<controller> validating_node;
395412
uint32_t num_blocks_to_producer_before_shutdown = 0;
413+
bool skip_validate = false;
396414
};
397415

398416
/**

0 commit comments

Comments
 (0)