diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 497116d9..e422a446 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -5779,7 +5779,7 @@ bool blockchain_storage::prevalidate_block(const block& bl) get_block_height(bl) <= m_core_runtime_config.hard_fork_03_starts_after_height ) { - if (bl.major_version == HF1_BLOCK_MAJOR_VERSION) + if (bl.major_version <= HF1_BLOCK_MAJOR_VERSION ) return true; else return false; diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index ff7b9762..bbd61e4c 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -219,10 +219,17 @@ bool test_generator::construct_block(currency::block& blk, const std::list& tx_list, const std::list& coin_stake_sources)//in case of PoS block { - if (height > m_hardfork_01_after_heigh) - blk.major_version = CURRENT_BLOCK_MAJOR_VERSION; - else +// if (height > m_hardfork_01_after_heigh) +// blk.major_version = CURRENT_BLOCK_MAJOR_VERSION; +// else +// blk.major_version = BLOCK_MAJOR_VERSION_INITAL; + + if (height <= m_hardfork_01_after_heigh) blk.major_version = BLOCK_MAJOR_VERSION_INITAL; + else if (height <= m_hardfork_03_after_heigh) + blk.major_version = HF1_BLOCK_MAJOR_VERSION; + else + blk.major_version = CURRENT_BLOCK_MAJOR_VERSION; blk.minor_version = CURRENT_BLOCK_MINOR_VERSION; blk.timestamp = timestamp; diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index b24bb27b..1f21fce7 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -1007,6 +1007,9 @@ int main(int argc, char* argv[]) GENERATE_AND_PLAY(hard_fork_1_chain_switch_pow_only); GENERATE_AND_PLAY(hard_fork_1_checkpoint_basic_test); GENERATE_AND_PLAY(hard_fork_1_pos_locked_height_vs_time); + GENERATE_AND_PLAY(hard_fork_1_pos_and_locked_coins); + + // Hardfork 2 tests GENERATE_AND_PLAY(hard_fork_2_tx_payer_in_wallet); diff --git a/tests/core_tests/hard_fork_1.cpp b/tests/core_tests/hard_fork_1.cpp index 6116fdd9..216c7dab 100644 --- a/tests/core_tests/hard_fork_1.cpp +++ b/tests/core_tests/hard_fork_1.cpp @@ -113,7 +113,7 @@ bool hard_fork_1_unlock_time_2_in_normal_tx::generate(std::vector& MAKE_NEXT_BLOCK(events, blk_3a, blk_2a, miner_acc); // hardfork should happen here MAKE_NEXT_BLOCK(events, blk_4a, blk_3a, miner_acc); // make sure hardfork went okay - CHECK_AND_ASSERT_MES(blk_3a.major_version != CURRENT_BLOCK_MAJOR_VERSION && blk_4a.major_version == CURRENT_BLOCK_MAJOR_VERSION, false, "hardfork did not happen as expected"); + CHECK_AND_ASSERT_MES(blk_3a.major_version != CURRENT_BLOCK_MAJOR_VERSION && blk_4a.major_version == HF1_BLOCK_MAJOR_VERSION, false, "hardfork did not happen as expected"); // @@ -357,7 +357,7 @@ bool hard_fork_1_checkpoint_basic_test::generate(std::vector& MAKE_NEXT_BLOCK(events, blk_3, blk_2, miner_acc); // <-- hard fork MAKE_NEXT_BLOCK(events, blk_4, blk_3, miner_acc); // make sure hardfork went okay - CHECK_AND_ASSERT_MES(blk_3.major_version != CURRENT_BLOCK_MAJOR_VERSION && blk_4.major_version == CURRENT_BLOCK_MAJOR_VERSION, false, "hardfork did not happen as expected"); + CHECK_AND_ASSERT_MES(blk_3.major_version != CURRENT_BLOCK_MAJOR_VERSION && blk_4.major_version == HF1_BLOCK_MAJOR_VERSION, false, "hardfork did not happen as expected"); // // after hardfork 1 @@ -397,7 +397,7 @@ bool hard_fork_1_checkpoint_basic_test::generate(std::vector& pos_block_builder pb; pb.step1_init_header(height, prev_id); - pb.m_block.major_version = CURRENT_BLOCK_MAJOR_VERSION; + pb.m_block.major_version = HF1_BLOCK_MAJOR_VERSION; pb.step2_set_txs(std::vector()); pb.step3_build_stake_kernel(stake_output_amount, stake_output_gidx, stake_output_key_image, diff, prev_id, null_hash, prev_block.timestamp); pb.step4_generate_coinbase_tx(generator.get_timestamps_median(prev_id), generator.get_already_generated_coins(prev_block), miner_acc.get_public_address(), stakeholder.get_public_address()); @@ -584,7 +584,7 @@ bool hard_fork_1_pos_and_locked_coins::generate(std::vector& e MAKE_NEXT_BLOCK(events, blk_2, blk_1r, miner_acc); MAKE_NEXT_BLOCK(events, blk_3, blk_2, miner_acc); // make sure hardfork went okay - CHECK_AND_ASSERT_MES(blk_2.major_version != CURRENT_BLOCK_MAJOR_VERSION && blk_3.major_version == CURRENT_BLOCK_MAJOR_VERSION, false, "hardfork did not happen as expected"); + CHECK_AND_ASSERT_MES(blk_2.major_version != CURRENT_BLOCK_MAJOR_VERSION && blk_3.major_version == HF1_BLOCK_MAJOR_VERSION, false, "hardfork did not happen as expected"); // try to make a PoS block with locked stake after the hardfork @@ -726,7 +726,7 @@ bool hard_fork_1_pos_locked_height_vs_time::generate(std::vector