Skip to content

Commit

Permalink
GH-1039 Move call to apply_blocks with startup
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Nov 26, 2024
1 parent ac8d2f0 commit 5773e88
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
3 changes: 3 additions & 0 deletions libraries/testing/tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,15 @@ namespace eosio::testing {
open(std::move(pfs), snapshot_chain_id, [&snapshot,&control=this->control]() {
control->startup( [](){}, []() { return false; }, snapshot );
});
apply_blocks();
}

void base_tester::open( protocol_feature_set&& pfs, const genesis_state& genesis, call_startup_t call_startup ) {
if (call_startup == call_startup_t::yes) {
open(std::move(pfs), genesis.compute_chain_id(), [&genesis,&control=this->control]() {
control->startup( [](){}, []() { return false; }, genesis );
});
apply_blocks();
} else {
open(std::move(pfs), genesis.compute_chain_id(), nullptr);
}
Expand All @@ -440,6 +442,7 @@ namespace eosio::testing {
open(std::move(pfs), expected_chain_id, [&control=this->control]() {
control->startup( [](){}, []() { return false; } );
});
apply_blocks();
}

void base_tester::push_block(const signed_block_ptr& b) {
Expand Down
3 changes: 1 addition & 2 deletions unittests/blocks_log_replay_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct blog_replay_fixture {
// Resume replay
eosio::testing::tester replay_chain_1(copied_config_1, *genesis, call_startup_t::no);
replay_chain_1.control->startup( [](){}, []()->bool{ return false; } );
replay_chain_1.apply_blocks();

// Make sure new chain contain the account created by original chain
BOOST_REQUIRE_NO_THROW(replay_chain_1.get_account("replay1"_n));
Expand All @@ -97,7 +98,6 @@ struct blog_replay_fixture {
// with last_irreversible_block_num and last_head_block_num
BOOST_CHECK(replay_chain_1.last_irreversible_block_num() == last_irreversible_block_num);
if (!remove_fork_db) {
replay_chain_1.apply_blocks();
BOOST_CHECK(replay_chain_1.head().block_num() == last_head_block_num);
} else {
BOOST_CHECK(replay_chain_1.head().block_num() == last_irreversible_block_num);
Expand Down Expand Up @@ -129,7 +129,6 @@ BOOST_FIXTURE_TEST_CASE(replay_through, blog_replay_fixture) try {
// Make sure replayed irreversible_block_num and head_block_num match
// with last_irreversible_block_num and last_head_block_num
BOOST_CHECK(replay_chain.last_irreversible_block_num() == last_irreversible_block_num);
replay_chain.apply_blocks();
BOOST_CHECK(replay_chain.head().block_num() == last_head_block_num);
} FC_LOG_AND_RETHROW()

Expand Down
3 changes: 1 addition & 2 deletions unittests/restart_chain_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class replay_tester : public base_tester {
control->applied_transaction().connect(on_applied_trx);
control->startup( [](){}, []() { return false; }, genesis );
});
apply_blocks();
}
using base_tester::produce_block;

Expand Down Expand Up @@ -163,7 +164,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( test_restart_from_block_log, T, testers ) {
remove_existing_states(copied_config);

tester from_block_log_chain(copied_config, *genesis);
from_block_log_chain.apply_blocks();

BOOST_REQUIRE_NO_THROW(from_block_log_chain.get_account("replay1"_n));
BOOST_REQUIRE_NO_THROW(from_block_log_chain.get_account("replay2"_n));
Expand Down Expand Up @@ -222,7 +222,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( test_light_validation_restart_from_block_log, T,
other_trace = t;
}
});
from_block_log_chain.apply_blocks();

BOOST_REQUIRE(other_trace);
BOOST_REQUIRE(other_trace->receipt);
Expand Down
1 change: 0 additions & 1 deletion unittests/savanna_cluster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ namespace savanna_cluster {
void open_from_snapshot(const std::string& snapshot) {
dlog("node ${i} - restoring from snapshot", ("i", _node_idx));
open(buffered_snapshot_suite::get_reader(snapshot));
apply_blocks();
}

std::vector<uint8_t> save_fsi() const {
Expand Down

0 comments on commit 5773e88

Please sign in to comment.