40 bool lift_up_difficulty(std::vector<test_event_entry>& events, std::vector<uint64_t>& timestamps,
41 std::vector<difficulty_type>& cummulative_difficulties,
test_generator& generator,
44 difficulty_type commulative_diffic = cummulative_difficulties.empty() ? 0 : cummulative_difficulties.back();
45 block blk_prev = blk_last;
46 for (
size_t i = 0; i < new_block_count; ++i)
54 commulative_diffic += diffic;
57 timestamps.erase(timestamps.begin());
58 cummulative_difficulties.erase(cummulative_difficulties.begin());
61 cummulative_difficulties.push_back(commulative_diffic);
63 events.push_back(blk_next);
71 #define BLOCK_VALIDATION_INIT_GENERATE() \ 72 GENERATE_ACCOUNT(miner_account); \ 73 MAKE_GENESIS_BLOCK(events, blk_0, miner_account, 1338224400); 84 events.push_back(blk_1);
97 events.push_back(blk_1);
111 events.push_back(blk_1);
126 events.push_back(blk_1);
139 events.push_back(blk_1);
152 reinterpret_cast<char &
>(prev_id) ^= 1;
154 events.push_back(blk_1);
173 std::vector<uint64_t> timestamps;
174 std::vector<difficulty_type> commulative_difficulties;
175 if (!lift_up_difficulty(events, timestamps, commulative_difficulties, generator, 2, blk_0, miner_account))
181 const block& blk_last = boost::get<block>(events.back());
192 while (0 == blk_3.
nonce);
194 events.push_back(blk_3);
208 events.push_back(blk_1);
220 --miner_tx.unlock_time;
224 events.push_back(blk_1);
236 ++miner_tx.unlock_time;
240 events.push_back(blk_1);
252 miner_tx.unlock_time = blk_0.timestamp - 10 * 60;
256 events.push_back(blk_1);
272 events.push_back(blk_1);
284 boost::get<txin_gen>(miner_tx.vin[0]).
height--;
288 events.push_back(blk_1);
300 boost::get<txin_gen>(miner_tx.vin[0]).
height++;
304 events.push_back(blk_1);
319 miner_tx.vin.push_back(in);
323 events.push_back(blk_1);
338 se.
amount = blk_0.miner_tx.vout[0].amount;
339 se.
push_output(0, boost::get<txout_to_key>(blk_0.miner_tx.vout[0].target).key, se.
amount);
344 std::vector<tx_source_entry> sources;
345 sources.push_back(se);
350 std::vector<tx_destination_entry> destinations;
351 destinations.push_back(de);
354 if (!
construct_tx(miner_account.
get_keys(), sources, destinations, boost::none, std::vector<uint8_t>(), tmp_tx, 0))
358 miner_tx.vin.push_back(tmp_tx.
vin[0]);
362 events.push_back(blk_1);
376 events.push_back(blk_1);
387 std::vector<tx_source_entry> sources;
388 sources.push_back(se);
393 std::vector<tx_destination_entry> destinations;
394 destinations.push_back(de);
397 if (!
construct_tx(miner_account.
get_keys(), sources, destinations, boost::none, std::vector<uint8_t>(), tmp_tx, 0))
401 miner_tx.vin[0] = tmp_tx.
vin[0];
405 events.push_back(blk_2);
417 miner_tx.vout[0].amount /= 2;
421 events.push_back(blk_1);
433 miner_tx.vout[0].amount *= 2;
437 events.push_back(blk_1);
449 miner_tx.vout.clear();
453 events.push_back(blk_1);
475 out_to_alice.
amount = miner_tx.vout[0].amount / 2;
476 miner_tx.vout[0].amount -= out_to_alice.amount;
478 miner_tx.vout.push_back(out_to_alice);
482 events.push_back(blk_1);
493 std::vector<crypto::hash> tx_hashes;
498 events.push_back(blk_1);
513 uint64_t portion = amount / tx_out_count;
514 uint64_t remainder = amount % tx_out_count;
516 miner_tx.vout.clear();
517 for (
size_t i = 0; i < tx_out_count; ++i)
522 miner_tx.vout.push_back(o);
529 miner_tx.vout.push_back(o);
538 events.push_back(blk_1);
546 : m_corrupt_blocks_begin_idx(0)
556 std::vector<uint64_t> timestamps;
557 std::vector<difficulty_type> cummulative_difficulties;
561 block blk_last = blk_0;
566 timestamps.push_back(blk_curr.timestamp);
567 cummulative_difficulties.push_back(++cummulative_diff);
575 blk_last = boost::get<block>(events.back());
577 if (!lift_up_difficulty(events, timestamps, cummulative_difficulties, generator, 1, blk_last, miner_account))
579 std::cout <<
"Block #" << events.size() <<
", difficulty: " << diffic << std::endl;
581 while (diffic < 1500);
583 blk_last = boost::get<block>(events.back());
584 MAKE_TX(events, tx_0, miner_account, miner_account,
MK_COINS(30), boost::get<block>(events[1]));
588 std::vector<crypto::hash> tx_hashes;
598 for (
size_t i = 0; i < blob.size(); ++i)
600 for (
size_t bit_idx = 0; bit_idx <
sizeof(blobdata::value_type) * 8; ++bit_idx)
603 blobdata::value_type& ch = sr_block.
data[i];
606 events.push_back(sr_block);
618 if (0 == m_corrupt_blocks_begin_idx || event_idx < m_corrupt_blocks_begin_idx)
631 m_corrupt_blocks_begin_idx = ev_index + 1;
bool generate(std::vector< test_event_entry > &events) const
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
bool generate(std::vector< test_event_entry > &events) const
bool generate(std::vector< test_event_entry > &events) const
crypto::public_key real_out_tx_key
bool generate(std::vector< test_event_entry > &events) const
difficulty_type next_difficulty(std::vector< uint64_t > timestamps, std::vector< difficulty_type > cumulative_difficulties, size_t target_seconds, uint8_t version)
uint64_t get_outs_etn_amount(const transaction &tx)
cryptonote::blobdata data
bool construct_tx(const account_keys &sender_account_keys, std::vector< tx_source_entry > &sources, const std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time)
#define REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT)
bool generate(std::vector< test_event_entry > &events) const
bool generate(std::vector< test_event_entry > &events) const
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key, txout_to_key_public > txout_target_v
#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
bool check_block_verification_context(const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
bool generate(std::vector< test_event_entry > &events) const
uint64_t get_transaction_weight(const transaction &tx, size_t blob_size)
#define DIFFICULTY_WINDOW
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
bool m_partial_block_reward
bool generate(std::vector< test_event_entry > &events) const
bool m_marked_as_orphaned
const account_keys & get_keys() const
#define MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, KEY)
std::vector< tx_out > vout
Holds cryptonote related classes and helpers.
std::vector< txin_v > vin
uint64_t get_current_blockchain_height() const
get the current height of the blockchain
bool construct_block_manually(cryptonote::block &blk, const cryptonote::block &prev_block, const cryptonote::account_base &miner_acc, int actual_params=bf_none, uint8_t major_ver=0, uint8_t minor_ver=0, uint64_t timestamp=0, const crypto::hash &prev_id=crypto::hash(), const cryptonote::difficulty_type &diffic=1, const cryptonote::transaction &miner_tx=cryptonote::transaction(), const std::vector< crypto::hash > &tx_hashes=std::vector< crypto::hash >(), size_t txs_sizes=0, size_t max_outs=999, uint8_t hf_version=1)
bool generate(std::vector< test_event_entry > &events) const
bool construct_block_manually_tx(cryptonote::block &blk, const cryptonote::block &prev_block, const cryptonote::account_base &miner_acc, const std::vector< crypto::hash > &tx_hashes, size_t txs_size)
bool generate(std::vector< test_event_entry > &events) const
handles core cryptonote functionality
#define REGISTER_CALLBACK(CB_NAME, CLBACK)
bool generate(std::vector< test_event_entry > &events) const
unsigned __int64 uint64_t
#define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW
#define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT
bool t_serializable_object_to_blob(const t_object &to, blobdata &b_blob)
bool generate(std::vector< test_event_entry > &events) const
crypto::public_key get_tx_pub_key_from_extra(const std::vector< uint8_t > &tx_extra, size_t pk_index)
#define MAKE_MINER_TX_MANUALLY(TX, BLK)
bool generate(std::vector< test_event_entry > &events) const
void push_output(uint64_t idx, const crypto::public_key &k, uint64_t amount)
bool generate(std::vector< test_event_entry > &events) const
size_t get_pool_transactions_count() const
get the total number of transactions in the pool
bool generate(std::vector< test_event_entry > &events) const
account_public_address addr
account_public_address m_account_address
bool generate(std::vector< test_event_entry > &events) const
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
boost::multiprecision::uint128_t difficulty_type
bool generate(std::vector< test_event_entry > &events) const
bool generate(std::vector< test_event_entry > &events) const
size_t real_output_in_tx_index
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
#define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN_V6
crypto::hash get_transaction_hash(const transaction &t)
bool generate(std::vector< test_event_entry > &events) const
bool m_added_to_main_chain
#define MAKE_TX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, HEAD)
#define DIFFICULTY_TARGET
bool generate(std::vector< test_event_entry > &events) const
crypto::hash get_block_hash(uint64_t height)
#define BLOCK_VALIDATION_INIT_GENERATE()
#define GENERATE_ACCOUNT(account)
bool generate(std::vector< test_event_entry > &events) const
#define DEFINE_TESTS_ERROR_CONTEXT(text)
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
bool m_verification_failed
uint64_t get_block_height(const block &b)
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1
bool generate(std::vector< test_event_entry > &events) const
bool generate(std::vector< test_event_entry > &events) const