From 266a0556ce9c4476a3aad5c111a4d3d537f3da58 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 9 Nov 2022 16:55:54 +0100 Subject: [PATCH] chaingen: 1) check_hardfork_inactive implemented, 2) check_hardfork_* callbacks now calls BCS::is_hardfork_active(), i.e. check against top_block_height+1 instead of top_block_height --- tests/core_tests/chaingen.cpp | 21 ++++++++++++++++++--- tests/core_tests/chaingen.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index f0d266c2..c362d812 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -2145,6 +2145,7 @@ test_chain_unit_enchanced::test_chain_unit_enchanced() REGISTER_CALLBACK_METHOD(test_chain_unit_enchanced, remove_stuck_txs); REGISTER_CALLBACK_METHOD(test_chain_unit_enchanced, check_offers_count); REGISTER_CALLBACK_METHOD(test_chain_unit_enchanced, check_hardfork_active); + REGISTER_CALLBACK_METHOD(test_chain_unit_enchanced, check_hardfork_inactive); } bool test_chain_unit_enchanced::configure_core(currency::core& c, size_t ev_index, const std::vector& events) @@ -2281,10 +2282,24 @@ bool test_chain_unit_enchanced::check_hardfork_active(currency::core& c, size_t const std::string& params = boost::get(events[ev_index]).callback_params; CHECK_AND_ASSERT_MES(epee::string_tools::hex_to_pod(params, hardfork_id_to_check), false, "hex_to_pod failed, params = " << params); - uint64_t top_block_height = c.get_top_block_height(); - if (!c.get_blockchain_storage().get_core_runtime_config().is_hardfork_active_for_height(hardfork_id_to_check, top_block_height)) + if (!c.get_blockchain_storage().is_hardfork_active(hardfork_id_to_check)) { - LOG_ERROR("Hardfork #" << hardfork_id_to_check << " is not active yet (top block height is " << top_block_height << ")"); + LOG_ERROR("Hardfork #" << hardfork_id_to_check << " is not active yet (top block height is " << c.get_top_block_height() << ")"); + return false; + } + + return true; +} + +bool test_chain_unit_enchanced::check_hardfork_inactive(currency::core& c, size_t ev_index, const std::vector& events) +{ + size_t hardfork_id_to_check = 0; + const std::string& params = boost::get(events[ev_index]).callback_params; + CHECK_AND_ASSERT_MES(epee::string_tools::hex_to_pod(params, hardfork_id_to_check), false, "hex_to_pod failed, params = " << params); + + if (c.get_blockchain_storage().is_hardfork_active(hardfork_id_to_check)) + { + LOG_ERROR("Hardfork #" << hardfork_id_to_check << " is active, which is not expected (top block height is " << c.get_top_block_height() << ")"); return false; } diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h index 56db1e4a..7bffd292 100644 --- a/tests/core_tests/chaingen.h +++ b/tests/core_tests/chaingen.h @@ -319,6 +319,7 @@ public: bool remove_stuck_txs(currency::core& c, size_t ev_index, const std::vector& events); bool check_offers_count(currency::core& c, size_t ev_index, const std::vector& events); bool check_hardfork_active(currency::core& c, size_t ev_index, const std::vector& events); + bool check_hardfork_inactive(currency::core& c, size_t ev_index, const std::vector& events); static bool is_event_mark_invalid_block(const test_event_entry& ev, bool use_global_gentime_settings = true); static bool is_event_mark_invalid_tx(const test_event_entry& ev, bool use_global_gentime_settings = true);