1
0
Fork 0
forked from lthn/blockchain

coretests: 1) ignoring invalid blocks/txs made optional (may be disabled if necessary); 2) hard_fork_2_no_new_structures_before_hf fixed

This commit is contained in:
sowle 2022-11-01 00:06:47 +01:00
parent cdb58b727f
commit 20e72f18fc
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
3 changed files with 36 additions and 20 deletions

View file

@ -2277,3 +2277,28 @@ bool test_chain_unit_enchanced::check_hardfork_active(currency::core& c, size_t
return true;
}
/*static*/ bool test_chain_unit_enchanced::is_event_mark_invalid_block(const test_event_entry& ev, bool use_global_gentime_settings /* = true */)
{
if (use_global_gentime_settings && !test_generator::get_test_gentime_settings().ignore_invalid_blocks)
return false;
if (typeid(callback_entry) != ev.type())
return false;
const callback_entry& ce = boost::get<callback_entry>(ev);
return ce.callback_name == "mark_invalid_block";
}
/*static*/ bool test_chain_unit_enchanced::is_event_mark_invalid_tx(const test_event_entry& ev, bool use_global_gentime_settings /* = true */)
{
if (use_global_gentime_settings && !test_generator::get_test_gentime_settings().ignore_invalid_txs)
return false;
if (typeid(callback_entry) != ev.type())
return false;
const callback_entry& ce = boost::get<callback_entry>(ev);
return ce.callback_name == "mark_invalid_tx";
}

View file

@ -221,6 +221,8 @@ struct test_gentime_settings
uint64_t dust_threshold = DEFAULT_DUST_THRESHOLD;
size_t rss_min_number_of_outputs = CURRENCY_TX_MIN_ALLOWED_OUTS; // for random split strategy: min (target) number of tx outputs, one output will be split into this many parts
size_t rss_num_digits_to_keep = CURRENCY_TX_OUTS_RND_SPLIT_DIGITS_TO_KEEP; // for random split strategy: number of digits to keep
bool ignore_invalid_blocks = true; // gen-time blockchain building: don't take into account blocks marked as invalid ("mark_invalid_block")
bool ignore_invalid_txs = true; // gen-time blockchain building: don't take into account txs marked as invalid ("mark_invalid_txs")
};
class test_generator;
@ -318,23 +320,8 @@ public:
bool check_offers_count(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
bool check_hardfork_active(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
static bool is_event_mark_invalid_block(const test_event_entry& ev)
{
if (typeid(callback_entry) != ev.type())
return false;
const callback_entry& ce = boost::get<callback_entry>(ev);
return ce.callback_name == "mark_invalid_block";
}
static bool is_event_mark_invalid_tx(const test_event_entry& ev)
{
if (typeid(callback_entry) != ev.type())
return false;
const callback_entry& ce = boost::get<callback_entry>(ev);
return ce.callback_name == "mark_invalid_tx";
}
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);
protected:
struct params_top_block

View file

@ -740,6 +740,10 @@ hard_fork_2_no_new_structures_before_hf::hard_fork_2_no_new_structures_before_hf
bool hard_fork_2_no_new_structures_before_hf::generate(std::vector<test_event_entry>& events) const
{
test_gentime_settings tgs = test_generator::get_test_gentime_settings();
tgs.ignore_invalid_txs = false; // this test pushes originally invalid tx_0, tx_1 and tx_2 which are good after HF2, so we'd like to avoid mess with the sources among txs
test_generator::set_test_gentime_settings(tgs);
bool r = false;
m_accounts.resize(TOTAL_ACCS_COUNT);
account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate();
@ -830,9 +834,9 @@ bool hard_fork_2_no_new_structures_before_hf::generate(std::vector<test_event_en
MAKE_NEXT_BLOCK(events, blk_6, blk_5, miner_acc);
MAKE_NEXT_BLOCK(events, blk_7, blk_6, miner_acc);
events.push_back(tx_0);
events.push_back(tx_1);
events.push_back(tx_2);
ADD_CUSTOM_EVENT(events, tx_0);
ADD_CUSTOM_EVENT(events, tx_1);
ADD_CUSTOM_EVENT(events, tx_2);
// tx_0 with tx_payer should be accepted after HF2