forked from lthn/blockchain
multiple fixes over old block verification tests
This commit is contained in:
parent
64a043a18f
commit
a83dedf2a4
8 changed files with 121 additions and 47 deletions
|
|
@ -6392,8 +6392,14 @@ bool blockchain_storage::is_hardfork_active(size_t hardfork_id) const
|
|||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::prevalidate_block(const block& bl)
|
||||
{
|
||||
|
||||
uint64_t block_height = get_block_height(bl);
|
||||
|
||||
|
||||
//before hard_fork1
|
||||
if (bl.major_version == BLOCK_MAJOR_VERSION_INITIAL && m_core_runtime_config.is_hardfork_active_for_height(1, block_height))
|
||||
return true;
|
||||
|
||||
// HF0
|
||||
if (!m_core_runtime_config.is_hardfork_active_for_height(1, block_height))
|
||||
{
|
||||
|
|
@ -6409,7 +6415,16 @@ bool blockchain_storage::prevalidate_block(const block& bl)
|
|||
return true;
|
||||
}
|
||||
|
||||
// >= HF3
|
||||
// HF3 and !HF4
|
||||
if (m_core_runtime_config.is_hardfork_active_for_height(3, block_height) &&
|
||||
!m_core_runtime_config.is_hardfork_active_for_height(4, block_height))
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(bl.major_version == HF3_BLOCK_MAJOR_VERSION, false, "HF3 incorrect block major version: " << (int)bl.major_version);
|
||||
CHECK_AND_ASSERT_MES(bl.minor_version <= HF3_BLOCK_MINOR_VERSION, false, "HF3 incorrect block minor version: " << (int)bl.minor_version);
|
||||
return true;
|
||||
}
|
||||
|
||||
// rule for unknown versions
|
||||
if (bl.major_version > CURRENT_BLOCK_MAJOR_VERSION)
|
||||
{
|
||||
LOG_ERROR("prevalidation failed for block " << get_block_hash(bl) << ": major block version " << static_cast<size_t>(bl.major_version) << " is incorrect, " << CURRENT_BLOCK_MAJOR_VERSION << " is expected" << ENDL
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#pragma once
|
||||
#include "boost/serialization/array.hpp"
|
||||
#include "misc_language.h"
|
||||
#include "string_tools.h"
|
||||
|
||||
|
|
@ -75,6 +76,11 @@ namespace currency
|
|||
else
|
||||
return CURRENT_BLOCK_MAJOR_VERSION;
|
||||
}
|
||||
|
||||
uint8_t get_block_minor_version_by_height(uint64_t height) const
|
||||
{
|
||||
return HF3_BLOCK_MINOR_VERSION;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#define TRANSACTION_VERSION_POST_HF4 2
|
||||
#define HF1_BLOCK_MAJOR_VERSION 1
|
||||
#define HF3_BLOCK_MAJOR_VERSION 2
|
||||
#define HF3_BLOCK_MINOR_VERSION 0
|
||||
#define CURRENT_BLOCK_MAJOR_VERSION 3
|
||||
|
||||
#define CURRENT_BLOCK_MINOR_VERSION 0
|
||||
|
|
@ -253,9 +254,9 @@
|
|||
#define ZANO_HARDFORK_04_AFTER_HEIGHT 999999999
|
||||
#else
|
||||
/////// Zarcanum Testnet Pre-Alpha //////////////////////////////
|
||||
#define ZANO_HARDFORK_01_AFTER_HEIGHT 1
|
||||
#define ZANO_HARDFORK_02_AFTER_HEIGHT 1
|
||||
#define ZANO_HARDFORK_03_AFTER_HEIGHT 1
|
||||
#define ZANO_HARDFORK_01_AFTER_HEIGHT 0
|
||||
#define ZANO_HARDFORK_02_AFTER_HEIGHT 0
|
||||
#define ZANO_HARDFORK_03_AFTER_HEIGHT 0
|
||||
#define ZANO_HARDFORK_04_AFTER_HEIGHT CURRENCY_MAX_BLOCK_NUMBER
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ namespace
|
|||
bool gen_block_big_major_version::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
|
||||
block blk_1;
|
||||
generator.construct_block_manually(blk_1, blk_0, miner_account, test_generator::bf_major_ver, CURRENT_BLOCK_MAJOR_VERSION + 1);
|
||||
|
|
@ -67,6 +68,7 @@ bool gen_block_big_major_version::generate(std::vector<test_event_entry>& events
|
|||
bool gen_block_big_minor_version::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
|
||||
block blk_1;
|
||||
generator.construct_block_manually(blk_1, blk_0, miner_account, test_generator::bf_minor_ver, 0, CURRENT_BLOCK_MINOR_VERSION + 1);
|
||||
|
|
@ -80,6 +82,7 @@ bool gen_block_big_minor_version::generate(std::vector<test_event_entry>& events
|
|||
bool gen_block_ts_not_checked::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_account, BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW - 2);
|
||||
|
||||
block blk_1;
|
||||
|
|
@ -94,6 +97,7 @@ bool gen_block_ts_not_checked::generate(std::vector<test_event_entry>& events) c
|
|||
bool gen_block_ts_in_past::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_account, BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW - 1);
|
||||
|
||||
uint64_t ts_below_median = boost::get<block>(events[BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW / 2 - 1]).timestamp;
|
||||
|
|
@ -109,7 +113,7 @@ bool gen_block_ts_in_past::generate(std::vector<test_event_entry>& events) const
|
|||
bool gen_block_ts_in_future::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
block blk_1;
|
||||
generator.construct_block_manually(blk_1, blk_0, miner_account, test_generator::bf_timestamp, 0, 0, time(NULL) + 60*60 + CURRENCY_BLOCK_FUTURE_TIME_LIMIT);
|
||||
events.push_back(blk_1);
|
||||
|
|
@ -122,7 +126,7 @@ bool gen_block_ts_in_future::generate(std::vector<test_event_entry>& events) con
|
|||
bool gen_block_invalid_prev_id::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
block blk_1;
|
||||
crypto::hash prev_id = get_block_hash(blk_0);
|
||||
reinterpret_cast<char &>(prev_id) ^= 1;
|
||||
|
|
@ -145,7 +149,7 @@ bool gen_block_invalid_prev_id::check_block_verification_context(const currency:
|
|||
bool gen_block_invalid_nonce::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
std::vector<uint64_t> timestamps;
|
||||
std::vector<wide_difficulty_type> commulative_difficulties;
|
||||
if (!lift_up_difficulty(events, timestamps, commulative_difficulties, generator, 2, blk_0, miner_account))
|
||||
|
|
@ -175,7 +179,7 @@ bool gen_block_invalid_nonce::generate(std::vector<test_event_entry>& events) co
|
|||
bool gen_block_no_miner_tx::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
transaction miner_tx;
|
||||
miner_tx = AUTO_VAL_INIT(miner_tx);
|
||||
|
||||
|
|
@ -207,7 +211,7 @@ bool gen_block_unlock_time_is_low::generate(std::vector<test_event_entry>& event
|
|||
bool gen_block_unlock_time_is_high::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
|
||||
set_tx_unlock_time(miner_tx, get_tx_max_unlock_time(miner_tx) + 1);
|
||||
|
||||
|
|
@ -239,7 +243,7 @@ bool gen_block_unlock_time_is_timestamp_in_past::generate(std::vector<test_event
|
|||
bool gen_block_unlock_time_is_timestamp_in_future::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
|
||||
set_tx_unlock_time(miner_tx, blk_0.timestamp + 3 * CURRENCY_MINED_MONEY_UNLOCK_WINDOW * DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN);
|
||||
|
||||
|
|
@ -255,7 +259,7 @@ bool gen_block_unlock_time_is_timestamp_in_future::generate(std::vector<test_eve
|
|||
bool gen_block_height_is_low::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
|
||||
boost::get<txin_gen>(miner_tx.vin[0]).height--;
|
||||
|
||||
|
|
@ -271,7 +275,7 @@ bool gen_block_height_is_low::generate(std::vector<test_event_entry>& events) co
|
|||
bool gen_block_height_is_high::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
|
||||
boost::get<txin_gen>(miner_tx.vin[0]).height++;
|
||||
|
||||
|
|
@ -287,7 +291,7 @@ bool gen_block_height_is_high::generate(std::vector<test_event_entry>& events) c
|
|||
bool gen_block_miner_tx_has_2_tx_gen_in::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
|
||||
|
||||
txin_gen in;
|
||||
|
|
@ -306,6 +310,7 @@ bool gen_block_miner_tx_has_2_tx_gen_in::generate(std::vector<test_event_entry>&
|
|||
bool gen_block_miner_tx_has_2_in::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
REWIND_BLOCKS(events, blk_0r, blk_0, miner_account);
|
||||
|
||||
GENERATE_ACCOUNT(alice);
|
||||
|
|
@ -348,8 +353,9 @@ bool gen_block_miner_tx_has_2_in::generate(std::vector<test_event_entry>& events
|
|||
}
|
||||
|
||||
bool gen_block_miner_tx_with_txin_to_key::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
|
||||
// This block has only one output
|
||||
block blk_1 = AUTO_VAL_INIT(blk_1);
|
||||
|
|
@ -397,7 +403,7 @@ bool gen_block_miner_tx_with_txin_to_key::generate(std::vector<test_event_entry>
|
|||
bool gen_block_miner_tx_out_is_small::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
|
||||
boost::get<currency::tx_out_bare>( miner_tx.vout[0]).amount /= 2;
|
||||
|
||||
|
|
@ -413,7 +419,7 @@ boost::get<currency::tx_out_bare>( miner_tx.vout[0]).amount /= 2;
|
|||
bool gen_block_miner_tx_out_is_big::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
|
||||
boost::get<currency::tx_out_bare>( miner_tx.vout[0]).amount *= 2;
|
||||
|
||||
|
|
@ -429,7 +435,7 @@ boost::get<currency::tx_out_bare>( miner_tx.vout[0]).amount *= 2;
|
|||
bool gen_block_miner_tx_has_no_out::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
|
||||
miner_tx.vout.clear();
|
||||
|
||||
|
|
@ -445,7 +451,7 @@ bool gen_block_miner_tx_has_no_out::generate(std::vector<test_event_entry>& even
|
|||
bool gen_block_miner_tx_has_out_to_alice::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
GENERATE_ACCOUNT(alice);
|
||||
|
||||
keypair txkey;
|
||||
|
|
@ -474,7 +480,7 @@ boost::get<currency::tx_out_bare>( miner_tx.vout[0]).amount -= out_to_alice.amo
|
|||
bool gen_block_has_invalid_tx::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
std::vector<crypto::hash> tx_hashes;
|
||||
tx_hashes.push_back(crypto::hash());
|
||||
|
||||
|
|
@ -490,7 +496,7 @@ bool gen_block_has_invalid_tx::generate(std::vector<test_event_entry>& events) c
|
|||
bool gen_block_is_too_big::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
// Creating a huge miner_tx, it will have a lot of outs
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
|
||||
static const size_t tx_out_count = CURRENCY_BLOCK_GRANTED_FULL_REWARD_ZONE / 2;
|
||||
|
|
@ -537,7 +543,7 @@ gen_block_invalid_binary_format::gen_block_invalid_binary_format()
|
|||
bool gen_block_invalid_binary_format::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
//wide_difficulty_type cummulative_diff = 1;
|
||||
|
||||
// Unlock blk_0 outputs
|
||||
|
|
@ -705,6 +711,7 @@ bool gen_block_wrong_version_agains_hardfork::c1(currency::core& c, size_t ev_in
|
|||
bool gen_block_wrong_version_agains_hardfork::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
BLOCK_VALIDATION_INIT_GENERATE();
|
||||
SET_HARDFORKS_TO_OLD_TESTS();
|
||||
DO_CALLBACK(events, "c1");
|
||||
return true;
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
return true;
|
||||
}
|
||||
currency::hard_forks_descriptor m_hardforks;
|
||||
mutable currency::hard_forks_descriptor m_hardforks;
|
||||
};
|
||||
|
||||
template<size_t expected_blockchain_height>
|
||||
|
|
@ -56,7 +56,7 @@ struct gen_block_accepted_base : public test_chain_unit_base
|
|||
}
|
||||
};
|
||||
|
||||
struct gen_block_big_major_version : public gen_block_verification_base<1>
|
||||
struct gen_block_big_major_version : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
|
@ -76,83 +76,83 @@ struct gen_block_ts_in_past : public gen_block_verification_base<BLOCKCHAIN_TIME
|
|||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_ts_in_future : public gen_block_verification_base<1>
|
||||
struct gen_block_ts_in_future : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_invalid_prev_id : public gen_block_verification_base<1>
|
||||
struct gen_block_invalid_prev_id : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
bool check_block_verification_context(const currency::block_verification_context& bvc, size_t event_idx, const currency::block& /*blk*/);
|
||||
};
|
||||
|
||||
struct gen_block_invalid_nonce : public gen_block_verification_base<3>
|
||||
struct gen_block_invalid_nonce : public gen_block_verification_base<4>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_no_miner_tx : public gen_block_verification_base<1>
|
||||
struct gen_block_no_miner_tx : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_unlock_time_is_low : public gen_block_verification_base<1>
|
||||
struct gen_block_unlock_time_is_low : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_unlock_time_is_high : public gen_block_verification_base<1>
|
||||
struct gen_block_unlock_time_is_high : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_unlock_time_is_timestamp_in_past : public gen_block_verification_base<1>
|
||||
struct gen_block_unlock_time_is_timestamp_in_past : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_unlock_time_is_timestamp_in_future : public gen_block_verification_base<1>
|
||||
struct gen_block_unlock_time_is_timestamp_in_future : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_height_is_low : public gen_block_verification_base<1>
|
||||
struct gen_block_height_is_low : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_height_is_high : public gen_block_verification_base<1>
|
||||
struct gen_block_height_is_high : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_miner_tx_has_2_tx_gen_in : public gen_block_verification_base<1>
|
||||
struct gen_block_miner_tx_has_2_tx_gen_in : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_miner_tx_has_2_in : public gen_block_verification_base<CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 1>
|
||||
struct gen_block_miner_tx_has_2_in : public gen_block_verification_base<CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_miner_tx_with_txin_to_key : public gen_block_verification_base<CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 2>
|
||||
struct gen_block_miner_tx_with_txin_to_key : public gen_block_verification_base<CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 3>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_miner_tx_out_is_small : public gen_block_verification_base<1>
|
||||
struct gen_block_miner_tx_out_is_small : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_miner_tx_out_is_big : public gen_block_verification_base<1>
|
||||
struct gen_block_miner_tx_out_is_big : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_miner_tx_has_no_out : public gen_block_verification_base<1>
|
||||
struct gen_block_miner_tx_has_no_out : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
|
@ -162,17 +162,17 @@ struct gen_block_miner_tx_has_out_to_alice : public gen_block_accepted_base<2>
|
|||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_has_invalid_tx : public gen_block_verification_base<1>
|
||||
struct gen_block_has_invalid_tx : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_is_too_big : public gen_block_verification_base<1>
|
||||
struct gen_block_is_too_big : public gen_block_verification_base<2>
|
||||
{
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
};
|
||||
|
||||
struct gen_block_wrong_version_agains_hardfork : public gen_block_verification_base<1>
|
||||
struct gen_block_wrong_version_agains_hardfork : public gen_block_verification_base<2>
|
||||
{
|
||||
public:
|
||||
gen_block_wrong_version_agains_hardfork();
|
||||
|
|
|
|||
|
|
@ -907,7 +907,7 @@ bool test_generator::construct_block(int64_t manual_timestamp_adjustment,
|
|||
{
|
||||
size_t height = get_block_height(prev_block) + 1;
|
||||
blk.major_version = actual_params & bf_major_ver ? major_ver : BLOCK_MAJOR_VERSION_INITIAL;
|
||||
blk.minor_version = actual_params & bf_minor_ver ? minor_ver : CURRENT_BLOCK_MINOR_VERSION;
|
||||
blk.minor_version = actual_params & bf_minor_ver ? minor_ver : m_hardforks.get_block_minor_version_by_height(height);
|
||||
blk.timestamp = actual_params & bf_timestamp ? timestamp : (height > 10 ? prev_block.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN: prev_block.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN-POW_DIFF_UP_TIMESTAMP_DELTA); // Keep difficulty unchanged
|
||||
blk.prev_id = actual_params & bf_prev_id ? prev_id : get_block_hash(prev_block);
|
||||
blk.tx_hashes = actual_params & bf_tx_hashes ? tx_hashes : std::vector<crypto::hash>();
|
||||
|
|
|
|||
|
|
@ -201,6 +201,17 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
struct core_hardforks_config
|
||||
{
|
||||
std::array<uint64_t, currency::hard_forks_descriptor::m_total_count> hardforks;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /*version*/)
|
||||
{
|
||||
ar & hardforks;
|
||||
}
|
||||
};
|
||||
|
||||
VARIANT_TAG(binary_archive, callback_entry, 0xcb);
|
||||
VARIANT_TAG(binary_archive, currency::account_base, 0xcc);
|
||||
VARIANT_TAG(binary_archive, serialized_block, 0xcd);
|
||||
|
|
@ -208,8 +219,10 @@ VARIANT_TAG(binary_archive, serialized_transaction, 0xce);
|
|||
VARIANT_TAG(binary_archive, event_visitor_settings, 0xcf);
|
||||
VARIANT_TAG(binary_archive, event_special_block, 0xd0);
|
||||
VARIANT_TAG(binary_archive, event_core_time, 0xd1);
|
||||
VARIANT_TAG(binary_archive, core_hardforks_config, 0xd2);
|
||||
|
||||
typedef boost::variant<currency::block, currency::transaction, currency::account_base, callback_entry, serialized_block, serialized_transaction, event_visitor_settings, event_special_block, event_core_time> test_event_entry;
|
||||
|
||||
typedef boost::variant<currency::block, currency::transaction, currency::account_base, callback_entry, serialized_block, serialized_transaction, event_visitor_settings, event_special_block, event_core_time, core_hardforks_config> test_event_entry;
|
||||
typedef std::unordered_map<crypto::hash, const currency::transaction*> map_hash2tx_t;
|
||||
|
||||
enum test_tx_split_strategy { tests_void_split_strategy, tests_null_split_strategy, tests_digits_split_strategy, tests_random_split_strategy };
|
||||
|
|
@ -248,7 +261,7 @@ private:
|
|||
callbacks_map m_callbacks;
|
||||
|
||||
protected:
|
||||
currency::hard_forks_descriptor m_hardforks;
|
||||
mutable currency::hard_forks_descriptor m_hardforks;
|
||||
};
|
||||
|
||||
struct offers_count_param
|
||||
|
|
@ -568,7 +581,7 @@ public:
|
|||
private:
|
||||
bool m_ignore_last_pow_in_wallets;
|
||||
|
||||
currency::hard_forks_descriptor m_hardforks;
|
||||
mutable currency::hard_forks_descriptor m_hardforks;
|
||||
|
||||
std::unordered_map<crypto::hash, block_info> m_blocks_info;
|
||||
static test_gentime_settings m_test_gentime_settings;
|
||||
|
|
@ -938,7 +951,11 @@ bool test_generator::construct_block_gentime_with_coinbase_cb(const currency::bl
|
|||
return false;
|
||||
|
||||
currency::wide_difficulty_type diff = get_difficulty_for_next_block(prev_id, true);
|
||||
r = construct_block_manually(b, prev_block, acc, test_generator::block_fields::bf_miner_tx, 0, 0, 0, prev_id, diff, miner_tx);
|
||||
r = construct_block_manually(b, prev_block, acc,
|
||||
test_generator::block_fields::bf_miner_tx| test_generator::block_fields::bf_major_ver | test_generator::block_fields::bf_minor_ver,
|
||||
m_hardforks.get_block_major_version_by_height(height),
|
||||
m_hardforks.get_block_minor_version_by_height(height),
|
||||
0, prev_id, diff, miner_tx);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_block_manually failed");
|
||||
|
||||
return true;
|
||||
|
|
@ -1238,6 +1255,19 @@ void append_vector_by_another_vector(U& dst, const V& src)
|
|||
|
||||
#define ADD_CUSTOM_EVENT(VEC_EVENTS, EVENT_OBJ) PRINT_EVENT_N_TEXT(VEC_EVENTS, #EVENT_OBJ); VEC_EVENTS.push_back(EVENT_OBJ)
|
||||
|
||||
|
||||
#define SET_HARDFORKS_TO_OLD_TESTS() \
|
||||
core_hardforks_config hardforks_update = AUTO_VAL_INIT(hardforks_update); \
|
||||
hardforks_update.hardforks = get_default_core_runtime_config().hard_forks.m_height_the_hardfork_n_active_after; \
|
||||
hardforks_update.hardforks[1] = 1440; \
|
||||
hardforks_update.hardforks[2] = 1800; \
|
||||
hardforks_update.hardforks[3] = 1801; \
|
||||
currency::hard_forks_descriptor hardforks_desc = AUTO_VAL_INIT(hardforks_desc); \
|
||||
hardforks_desc.m_height_the_hardfork_n_active_after = hardforks_update.hardforks; \
|
||||
generator.set_hardforks(hardforks_desc); \
|
||||
m_hardforks.m_height_the_hardfork_n_active_after = hardforks_desc.m_height_the_hardfork_n_active_after; \
|
||||
events.push_back(hardforks_update);
|
||||
|
||||
// --- gentime wallet helpers -----------------------------------------------------------------------
|
||||
|
||||
#define CREATE_TEST_WALLET(WLT_VAR, ACCOUNT, GENESIS_BLOCK) \
|
||||
|
|
|
|||
|
|
@ -526,6 +526,20 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool operator()(const core_hardforks_config& e) const
|
||||
{
|
||||
currency::core_runtime_config crc = m_c.get_blockchain_storage().get_core_runtime_config();
|
||||
crc.hard_forks.m_height_the_hardfork_n_active_after = e.hardforks;
|
||||
m_c.get_blockchain_storage().set_core_runtime_config(crc);
|
||||
std::stringstream ss; ss << "core_hardforks updated:" << ENDL;
|
||||
for (size_t i = 0; i != crc.hard_forks.m_height_the_hardfork_n_active_after.size(); i++)
|
||||
{
|
||||
ss << i << ": " << crc.hard_forks.m_height_the_hardfork_n_active_after[i] << ENDL;
|
||||
}
|
||||
log_event(ss.str());
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
void log_event(const std::string& event_type) const
|
||||
{
|
||||
|
|
@ -790,6 +804,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
|
||||
// TODO // GENERATE_AND_PLAY(wallet_spend_form_auditable_and_track);
|
||||
GENERATE_AND_PLAY(gen_block_big_major_version);
|
||||
|
||||
GENERATE_AND_PLAY(pos_minting_tx_packing);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue