From dd64c805d7f4537b26aa841ea50f063e65c3e14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=D1=91pa=20Dolgorukov?= <63650851+stepan-dolgorukov@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:24:18 +0500 Subject: [PATCH] coretests: Update "block_with_correct_prev_id_on_wrong_height" test (#499) * Core tests: implement the test "block_with_correct_prev_id_on_wrong_height" * Core tests: update "block_with_correct_prev_id_on_wrong_height" test --- tests/core_tests/block_validation.cpp | 34 +++++++++++++++++++-------- tests/core_tests/block_validation.h | 3 --- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/tests/core_tests/block_validation.cpp b/tests/core_tests/block_validation.cpp index 75c453e2..bb1861bb 100644 --- a/tests/core_tests/block_validation.cpp +++ b/tests/core_tests/block_validation.cpp @@ -696,7 +696,7 @@ bool gen_block_wrong_version_agains_hardfork::generate(std::vector& events) const @@ -707,26 +707,40 @@ bool block_with_correct_prev_id_on_wrong_height::generate(std::vector& events) const { - currency::block_verification_context context_blk_2{}; + block blk_2{}; - CHECK_AND_ASSERT_EQ(boost::get(m_blk_2.miner_tx.vin.front()).height, 10); - CHECK_AND_ASSERT_EQ(c.get_blockchain_storage().add_new_block(m_blk_2, context_blk_2), false); + { + const auto serialized_block{boost::get(events.at(ev_index)).callback_params}; + + CHECK_AND_ASSERT_EQ(t_unserializable_object_from_blob(blk_2, serialized_block), true); + } + + { + currency::block_verification_context context_blk_2{}; + + CHECK_AND_ASSERT_EQ(boost::get(blk_2.miner_tx.vin.front()).height, 10); + // Make sure, that it's impossible to insert blk_2. + CHECK_AND_ASSERT_EQ(c.get_blockchain_storage().add_new_block(blk_2, context_blk_2), false); + } return true; } diff --git a/tests/core_tests/block_validation.h b/tests/core_tests/block_validation.h index 2075c76d..59e4c149 100644 --- a/tests/core_tests/block_validation.h +++ b/tests/core_tests/block_validation.h @@ -194,9 +194,6 @@ struct block_with_correct_prev_id_on_wrong_height : public gen_block_verificatio block_with_correct_prev_id_on_wrong_height(); bool generate(std::vector& events) const; bool assert_blk_2_has_wrong_height(currency::core& c, size_t ev_index, const std::vector& events) const; - -private: - mutable currency::block m_blk_2{}; }; struct block_reward_in_main_chain_basic : wallet_test