Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug in libtester produce_blocks and make SHiP unit tests work in both Savanna and Legacy #367

Merged
merged 7 commits into from
Jul 15, 2024
4 changes: 4 additions & 0 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4968,6 +4968,10 @@ void controller::allow_voting(bool val) {
my->allow_voting = val;
}

bool controller::get_allow_voting_flag() {
return my->allow_voting;
}

void controller::set_async_voting(async_t val) {
my->async_voting = val;
}
Expand Down
1 change: 1 addition & 0 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ namespace eosio::chain {
void sign_block( const signer_callback_type& signer_callback );
void commit_block(block_report& br);
void allow_voting(bool val);
bool get_allow_voting_flag();
void set_async_voting(async_t val);
void set_async_aggregation(async_t val);
void maybe_switch_forks(const forked_callback_t& cb, const trx_meta_cache_lookup& trx_lookup);
Expand Down
9 changes: 7 additions & 2 deletions libraries/testing/tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,15 @@ namespace eosio::testing {

signed_block_ptr base_tester::produce_blocks( uint32_t n, bool empty ) {
signed_block_ptr res;
bool allow_voting_originally = control->get_allow_voting_flag();

for (uint32_t i = 0; i < n; ++i) {
// for performance, only vote on the last four to move finality
// For performance, only vote on the last four to move finality.
// Modify allow_voting only if it was set to true originally;
// otherwise the allow_voting would be set to true when `i >= 4` even though the user of
// `produce_blocks` wants it to be true.
// This is 4 instead of 3 because the extra block has to be produced to log_irreversible
if (n > 4)
if (allow_voting_originally && n > 4)
control->allow_voting(i >= n - 4);
res = empty ? produce_empty_block() : produce_block();
}
Expand Down
Loading