From fd50b3ad8d199ca9133f7e3f52cf16502733cb14 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 3 May 2023 22:16:40 +0200 Subject: [PATCH] fixed hard_fork_1_pos_and_locked_coins test --- tests/core_tests/block_validation.h | 4 ++++ tests/core_tests/chaingen_main.cpp | 2 -- tests/core_tests/hard_fork_1.cpp | 7 ++++++- tests/core_tests/hard_fork_1.h | 1 + tests/core_tests/multisig_wallet_tests.cpp | 5 ++++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/core_tests/block_validation.h b/tests/core_tests/block_validation.h index 37bb075e..74aaefa6 100644 --- a/tests/core_tests/block_validation.h +++ b/tests/core_tests/block_validation.h @@ -52,6 +52,10 @@ struct gen_block_accepted_base : public test_chain_unit_base { gen_block_accepted_base() { + m_hardforks.m_height_the_hardfork_n_active_after[1] = 1440; + m_hardforks.m_height_the_hardfork_n_active_after[2] = 1800; + m_hardforks.m_height_the_hardfork_n_active_after[3] = 1801; + m_hardforks.m_height_the_hardfork_n_active_after[4] = 50000000000; REGISTER_CALLBACK("check_block_accepted", gen_block_accepted_base::check_block_accepted); } diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index b163e524..1ae27e47 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -1069,8 +1069,6 @@ int main(int argc, char* argv[]) 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 fa12a578..861b29aa 100644 --- a/tests/core_tests/hard_fork_1.cpp +++ b/tests/core_tests/hard_fork_1.cpp @@ -27,6 +27,10 @@ void remove_unlock_v2_entries_from_extra(extra_t& extra) hard_fork_1_base_test::hard_fork_1_base_test(size_t hardfork_height) : m_hardfork_height(hardfork_height) { + m_hardforks.m_height_the_hardfork_n_active_after[1] = 1440; + m_hardforks.m_height_the_hardfork_n_active_after[2] = 1800; + m_hardforks.m_height_the_hardfork_n_active_after[3] = 1801; + m_hardforks.m_height_the_hardfork_n_active_after[4] = 50000000000; REGISTER_CALLBACK_METHOD(hard_fork_1_base_test, configure_core); } @@ -475,11 +479,12 @@ hard_fork_1_pos_and_locked_coins::hard_fork_1_pos_and_locked_coins() bool hard_fork_1_pos_and_locked_coins::generate(std::vector& events) const { + random_state_test_restorer::reset_random(); bool r = false; GENERATE_ACCOUNT(miner_acc); GENERATE_ACCOUNT(alice_acc); GENERATE_ACCOUNT(bob_acc); - MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time()); + MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, starter_timestamp); generator.set_hardfork_height(1, m_hardfork_height); DO_CALLBACK(events, "configure_core"); REWIND_BLOCKS_N_WITH_TIME(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 3); diff --git a/tests/core_tests/hard_fork_1.h b/tests/core_tests/hard_fork_1.h index fade139f..321a0577 100644 --- a/tests/core_tests/hard_fork_1.h +++ b/tests/core_tests/hard_fork_1.h @@ -45,6 +45,7 @@ struct hard_fork_1_pos_and_locked_coins : public hard_fork_1_base_test bool generate(std::vector& events) const; bool check_outputs_with_unique_amount(currency::core& c, size_t ev_index, const std::vector& events); + uint64_t starter_timestamp = 1564434640; }; struct hard_fork_1_pos_locked_height_vs_time : public hard_fork_1_base_test diff --git a/tests/core_tests/multisig_wallet_tests.cpp b/tests/core_tests/multisig_wallet_tests.cpp index acf4d959..91171dbf 100644 --- a/tests/core_tests/multisig_wallet_tests.cpp +++ b/tests/core_tests/multisig_wallet_tests.cpp @@ -1632,7 +1632,10 @@ multisig_and_checkpoints::multisig_and_checkpoints() { // NOTE: This test is made deterministic to be able to correctly set up checkpoint. random_state_test_restorer::reset_random(); // random generator's state was previously stored, will be restore on dtor (see also m_random_state_test_restorer) - + m_hardforks.m_height_the_hardfork_n_active_after[1] = 1440; + m_hardforks.m_height_the_hardfork_n_active_after[2] = 1800; + m_hardforks.m_height_the_hardfork_n_active_after[3] = 1801; + m_hardforks.m_height_the_hardfork_n_active_after[4] = 50000000000; REGISTER_CALLBACK_METHOD(multisig_and_checkpoints, set_cp); }