提交 09d16d94 编写于 作者: A Andrianto Lie

Add additional unit test for bootseq_tests

上级 e4980b1e
......@@ -85,6 +85,9 @@ namespace eosio { namespace testing {
virtual 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*/ ) = 0;
void produce_blocks( uint32_t n = 1, bool empty = false );
void produce_blocks_until_end_of_round();
void produce_blocks_for_n_rounds(const uint32_t num_of_rounds = 1);
// Produce minimal number of blocks as possible to spend the given time without having any producer become inactive
void produce_min_num_of_blocks_to_spend_time_wo_inactive_prod(const fc::microseconds target_elapsed_time = fc::microseconds());
signed_block_ptr push_block(signed_block_ptr b);
transaction_trace_ptr push_transaction( packed_transaction& trx, fc::time_point deadline = fc::time_point::maximum(), uint32_t billed_cpu_time_us = DEFAULT_BILLED_CPU_TIME_US );
......
......@@ -180,11 +180,36 @@ namespace eosio { namespace testing {
void base_tester::produce_blocks_until_end_of_round() {
while( control->pending_block_state()->has_pending_producers() ) {
uint64_t blocks_per_round;
while(true) {
blocks_per_round = control->active_producers().producers.size() * config::producer_repetitions;
produce_block();
if (control->head_block_num() % blocks_per_round == (blocks_per_round - 1)) break;
}
}
void base_tester::produce_blocks_for_n_rounds(const uint32_t num_of_rounds) {
for(uint32_t i = 0; i < num_of_rounds; i++) {
produce_blocks_until_end_of_round();
}
}
void base_tester::produce_min_num_of_blocks_to_spend_time_wo_inactive_prod(const fc::microseconds target_elapsed_time) {
fc::microseconds elapsed_time;
while (elapsed_time < target_elapsed_time) {
for(uint32_t i = 0; i < control->head_block_state()->active_schedule.producers.size(); i++) {
const auto time_to_skip = fc::milliseconds(config::producer_repetitions * config::block_interval_ms);
produce_block(time_to_skip);
elapsed_time += time_to_skip;
}
// if it is more than 24 hours, producer will be marked as inactive
const auto time_to_skip = fc::seconds(23 * 60 * 60);
produce_block(time_to_skip);
elapsed_time += time_to_skip;
}
}
void base_tester::set_transaction_headers( signed_transaction& trx, uint32_t expiration, uint32_t delay_sec ) const {
trx.expiration = control->head_block_time() + fc::seconds(expiration);
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册