42 size_t target_block_weight,
uint64_t fee = 0)
49 while (target_tx_weight != current_weight)
55 if (target_tx_weight < current_weight)
57 size_t diff = current_weight - target_tx_weight;
58 if (diff <= miner_tx.
extra.size())
59 miner_tx.
extra.resize(miner_tx.
extra.size() - diff);
65 size_t diff = target_tx_weight - current_weight;
66 miner_tx.
extra.resize(miner_tx.
extra.size() + diff);
78 std::vector<size_t> block_weights;
94 bool rewind_blocks(std::vector<test_event_entry>& events,
test_generator& generator,
block& blk,
const block& blk_prev,
98 for (
size_t i = 0; i < block_count; ++i)
101 if (!construct_max_weight_block(generator, blk_i, blk, miner_account))
104 events.push_back(blk_i);
114 BOOST_FOREACH(
auto& o, tx.
vout)
121 : m_invalid_block_index(0)
147 events.push_back(blk_1_bad_1);
153 events.push_back(blk_1_bad_2);
156 if (!construct_max_weight_block(generator, blk_1, blk_0r, miner_account))
158 events.push_back(blk_1);
181 std::list<transaction> txs_0;
194 std::vector<size_t> block_weights;
204 std::vector<crypto::hash> txs_1_hashes;
210 0, 0, 0,
crypto::hash(), 0, miner_tx, txs_1_hashes, txs_1_weight);
212 events.push_back(blk_8);
223 if (m_invalid_block_index == event_idx)
225 m_invalid_block_index = 0;
236 m_invalid_block_index = ev_index + 1;
242 m_checked_blocks_indices.push_back(ev_index - 1);
250 std::array<uint64_t, 7> blk_rewards;
253 blk_rewards[1] = 1260000000000;
254 uint64_t cumulative_reward = blk_rewards[0] + blk_rewards[1];
255 for (
size_t i = 2; i < blk_rewards.size(); ++i)
258 cumulative_reward += blk_rewards[i];
261 for (
size_t i = 0; i < 5; ++i)
263 block blk_i = boost::get<block>(events[m_checked_blocks_indices[i]]);
267 block blk_n1 = boost::get<block>(events[m_checked_blocks_indices[5]]);
270 block blk_n2 = boost::get<block>(events[m_checked_blocks_indices[6]]);
273 block blk_n3 = boost::get<block>(events[m_checked_blocks_indices[7]]);
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
#define EMISSION_SPEED_FACTOR_PER_MINUTE
#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1)
bool get_tx_fee(const transaction &tx, uint64_t &fee)
#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
#define TESTS_DEFAULT_FEE
uint64_t get_transaction_weight(const transaction &tx, size_t blob_size)
bool check_block_rewards(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
transaction construct_tx_with_fee(std::vector< test_event_entry > &events, const block &blk_head, const account_base &acc_from, const var_addr_t &to, uint64_t amount, uint64_t fee)
std::vector< uint8_t > extra
const account_keys & get_keys() const
std::vector< tx_out > vout
Holds cryptonote related classes and helpers.
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
handles core cryptonote functionality
#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS)
unsigned __int64 uint64_t
#define REGISTER_CALLBACK_METHOD(CLASS, METHOD)
bool check_block_verification_context(const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &blk)
type_vec_type median(std::vector< type_vec_type > &v)
#define CRYPTONOTE_REWARD_BLOCKS_WINDOW
account_public_address m_account_address
#define MAKE_ACCOUNT(VEC_EVENTS, account)
crypto::hash get_transaction_hash(const transaction &t)
uint64_t get_already_generated_coins(const crypto::hash &blk_id) const
crypto::hash get_block_hash(uint64_t height)
bool construct_miner_tx(size_t height, size_t median_weight, uint64_t already_generated_coins, size_t current_block_weight, uint64_t fee, const account_public_address &miner_address, transaction &tx, const blobdata &extra_nonce, size_t max_outs, uint8_t hard_fork_version, network_type nettype)
#define GENERATE_ACCOUNT(account)
bool mark_checked_block(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool mark_invalid_block(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
#define DEFINE_TESTS_ERROR_CONTEXT(text)
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST)
bool m_verification_failed
void get_last_n_block_weights(std::vector< size_t > &block_weights, const crypto::hash &head, size_t n) const
uint64_t get_block_height(const block &b)
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1