mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-23 01:28:53 +00:00
Merge pull request #6785
4a9bd8f
core_tests: remove hardcoded hf version (monermooo-monero)1dc427d
core_tests: fix failures after v13 (moneromooo-monero)
This commit is contained in:
commit
51bf6b5842
@ -87,6 +87,7 @@ bool gen_bp_tx_validation_base::generate_with(std::vector<test_event_entry>& eve
|
|||||||
std::vector<transaction> rct_txes;
|
std::vector<transaction> rct_txes;
|
||||||
cryptonote::block blk_txes;
|
cryptonote::block blk_txes;
|
||||||
std::vector<crypto::hash> starting_rct_tx_hashes;
|
std::vector<crypto::hash> starting_rct_tx_hashes;
|
||||||
|
uint64_t fees = 0;
|
||||||
static const uint64_t input_amounts_available[] = {5000000000000, 30000000000000, 100000000000, 80000000000};
|
static const uint64_t input_amounts_available[] = {5000000000000, 30000000000000, 100000000000, 80000000000};
|
||||||
for (size_t n = 0; n < n_txes; ++n)
|
for (size_t n = 0; n < n_txes; ++n)
|
||||||
{
|
{
|
||||||
@ -166,15 +167,19 @@ bool gen_bp_tx_validation_base::generate_with(std::vector<test_event_entry>& eve
|
|||||||
while (amounts_paid[0] != (size_t)-1)
|
while (amounts_paid[0] != (size_t)-1)
|
||||||
++amounts_paid;
|
++amounts_paid;
|
||||||
++amounts_paid;
|
++amounts_paid;
|
||||||
|
|
||||||
|
uint64_t fee = 0;
|
||||||
|
get_tx_fee(rct_txes.back(), fee);
|
||||||
|
fees += fee;
|
||||||
}
|
}
|
||||||
if (!valid)
|
if (!valid)
|
||||||
DO_CALLBACK(events, "mark_invalid_tx");
|
DO_CALLBACK(events, "mark_invalid_tx");
|
||||||
events.push_back(rct_txes);
|
events.push_back(rct_txes);
|
||||||
|
|
||||||
CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk_txes, blk_last, miner_account,
|
CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk_txes, blk_last, miner_account,
|
||||||
test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_tx_hashes | test_generator::bf_hf_version | test_generator::bf_max_outs,
|
test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_tx_hashes | test_generator::bf_hf_version | test_generator::bf_max_outs | test_generator::bf_tx_fees,
|
||||||
hf_version, hf_version, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long
|
hf_version, hf_version, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long
|
||||||
crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 6, 10),
|
crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 6, hf_version, fees),
|
||||||
false, "Failed to generate block");
|
false, "Failed to generate block");
|
||||||
if (!valid)
|
if (!valid)
|
||||||
DO_CALLBACK(events, "mark_invalid_block");
|
DO_CALLBACK(events, "mark_invalid_block");
|
||||||
|
@ -226,11 +226,9 @@ uint64_t test_generator::get_already_generated_coins(const cryptonote::block& bl
|
|||||||
return get_already_generated_coins(blk_hash);
|
return get_already_generated_coins(blk_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_generator::add_block(const cryptonote::block& blk, size_t txs_weight, std::vector<size_t>& block_weights, uint64_t already_generated_coins, uint8_t hf_version)
|
void test_generator::add_block(const cryptonote::block& blk, size_t txs_weight, std::vector<size_t>& block_weights, uint64_t already_generated_coins, uint64_t block_reward, uint8_t hf_version)
|
||||||
{
|
{
|
||||||
const size_t block_weight = txs_weight + get_transaction_weight(blk.miner_tx);
|
const size_t block_weight = txs_weight + get_transaction_weight(blk.miner_tx);
|
||||||
uint64_t block_reward;
|
|
||||||
get_block_reward(misc_utils::median(block_weights), block_weight, already_generated_coins, block_reward, hf_version);
|
|
||||||
m_blocks_info[get_block_hash(blk)] = block_info(blk.prev_id, already_generated_coins + block_reward, block_weight);
|
m_blocks_info[get_block_hash(blk)] = block_info(blk.prev_id, already_generated_coins + block_reward, block_weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +309,8 @@ bool test_generator::construct_block(cryptonote::block& blk, uint64_t height, co
|
|||||||
//blk.tree_root_hash = get_tx_tree_hash(blk);
|
//blk.tree_root_hash = get_tx_tree_hash(blk);
|
||||||
|
|
||||||
fill_nonce(blk, get_test_difficulty(hf_ver), height);
|
fill_nonce(blk, get_test_difficulty(hf_ver), height);
|
||||||
add_block(blk, txs_weight, block_weights, already_generated_coins, hf_ver ? hf_ver.get() : 1);
|
const uint64_t block_reward = get_outs_money_amount(blk.miner_tx) - total_fee;
|
||||||
|
add_block(blk, txs_weight, block_weights, already_generated_coins, block_reward, hf_ver ? hf_ver.get() : 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -345,7 +344,8 @@ bool test_generator::construct_block_manually(block& blk, const block& prev_bloc
|
|||||||
const crypto::hash& prev_id/* = crypto::hash()*/, const difficulty_type& diffic/* = 1*/,
|
const crypto::hash& prev_id/* = crypto::hash()*/, const difficulty_type& diffic/* = 1*/,
|
||||||
const transaction& miner_tx/* = transaction()*/,
|
const transaction& miner_tx/* = transaction()*/,
|
||||||
const std::vector<crypto::hash>& tx_hashes/* = std::vector<crypto::hash>()*/,
|
const std::vector<crypto::hash>& tx_hashes/* = std::vector<crypto::hash>()*/,
|
||||||
size_t txs_weight/* = 0*/, size_t max_outs/* = 0*/, uint8_t hf_version/* = 1*/)
|
size_t txs_weight/* = 0*/, size_t max_outs/* = 0*/, uint8_t hf_version/* = 1*/,
|
||||||
|
uint64_t fees/* = 0*/)
|
||||||
{
|
{
|
||||||
blk.major_version = actual_params & bf_major_ver ? major_ver : CURRENT_BLOCK_MAJOR_VERSION;
|
blk.major_version = actual_params & bf_major_ver ? major_ver : CURRENT_BLOCK_MAJOR_VERSION;
|
||||||
blk.minor_version = actual_params & bf_minor_ver ? minor_ver : CURRENT_BLOCK_MINOR_VERSION;
|
blk.minor_version = actual_params & bf_minor_ver ? minor_ver : CURRENT_BLOCK_MINOR_VERSION;
|
||||||
@ -354,6 +354,7 @@ bool test_generator::construct_block_manually(block& blk, const block& prev_bloc
|
|||||||
blk.tx_hashes = actual_params & bf_tx_hashes ? tx_hashes : std::vector<crypto::hash>();
|
blk.tx_hashes = actual_params & bf_tx_hashes ? tx_hashes : std::vector<crypto::hash>();
|
||||||
max_outs = actual_params & bf_max_outs ? max_outs : 9999;
|
max_outs = actual_params & bf_max_outs ? max_outs : 9999;
|
||||||
hf_version = actual_params & bf_hf_version ? hf_version : 1;
|
hf_version = actual_params & bf_hf_version ? hf_version : 1;
|
||||||
|
fees = actual_params & bf_tx_fees ? fees : 0;
|
||||||
|
|
||||||
size_t height = get_block_height(prev_block) + 1;
|
size_t height = get_block_height(prev_block) + 1;
|
||||||
uint64_t already_generated_coins = get_already_generated_coins(prev_block);
|
uint64_t already_generated_coins = get_already_generated_coins(prev_block);
|
||||||
@ -367,7 +368,7 @@ bool test_generator::construct_block_manually(block& blk, const block& prev_bloc
|
|||||||
{
|
{
|
||||||
size_t current_block_weight = txs_weight + get_transaction_weight(blk.miner_tx);
|
size_t current_block_weight = txs_weight + get_transaction_weight(blk.miner_tx);
|
||||||
// TODO: This will work, until size of constructed block is less then CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE
|
// TODO: This will work, until size of constructed block is less then CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE
|
||||||
if (!construct_miner_tx(height, misc_utils::median(block_weights), already_generated_coins, current_block_weight, 0, miner_acc.get_keys().m_account_address, blk.miner_tx, blobdata(), max_outs, hf_version))
|
if (!construct_miner_tx(height, misc_utils::median(block_weights), already_generated_coins, current_block_weight, fees, miner_acc.get_keys().m_account_address, blk.miner_tx, blobdata(), max_outs, hf_version))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +377,8 @@ bool test_generator::construct_block_manually(block& blk, const block& prev_bloc
|
|||||||
difficulty_type a_diffic = actual_params & bf_diffic ? diffic : get_test_difficulty(hf_version);
|
difficulty_type a_diffic = actual_params & bf_diffic ? diffic : get_test_difficulty(hf_version);
|
||||||
fill_nonce(blk, a_diffic, height);
|
fill_nonce(blk, a_diffic, height);
|
||||||
|
|
||||||
add_block(blk, txs_weight, block_weights, already_generated_coins, hf_version);
|
const uint64_t block_reward = get_outs_money_amount(blk.miner_tx) - fees;
|
||||||
|
add_block(blk, txs_weight, block_weights, already_generated_coins, block_reward, hf_version);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,8 @@ public:
|
|||||||
bf_tx_hashes = 1 << 5,
|
bf_tx_hashes = 1 << 5,
|
||||||
bf_diffic = 1 << 6,
|
bf_diffic = 1 << 6,
|
||||||
bf_max_outs = 1 << 7,
|
bf_max_outs = 1 << 7,
|
||||||
bf_hf_version= 1 << 8
|
bf_hf_version= 1 << 8,
|
||||||
|
bf_tx_fees = 1 << 9
|
||||||
};
|
};
|
||||||
|
|
||||||
test_generator(): m_events(nullptr) {}
|
test_generator(): m_events(nullptr) {}
|
||||||
@ -235,7 +236,7 @@ public:
|
|||||||
uint64_t get_already_generated_coins(const crypto::hash& blk_id) const;
|
uint64_t get_already_generated_coins(const crypto::hash& blk_id) const;
|
||||||
uint64_t get_already_generated_coins(const cryptonote::block& blk) const;
|
uint64_t get_already_generated_coins(const cryptonote::block& blk) const;
|
||||||
|
|
||||||
void add_block(const cryptonote::block& blk, size_t tsx_size, std::vector<size_t>& block_weights, uint64_t already_generated_coins,
|
void add_block(const cryptonote::block& blk, size_t tsx_size, std::vector<size_t>& block_weights, uint64_t already_generated_coins, uint64_t block_reward,
|
||||||
uint8_t hf_version = 1);
|
uint8_t hf_version = 1);
|
||||||
bool construct_block(cryptonote::block& blk, uint64_t height, const crypto::hash& prev_id,
|
bool construct_block(cryptonote::block& blk, uint64_t height, const crypto::hash& prev_id,
|
||||||
const cryptonote::account_base& miner_acc, uint64_t timestamp, uint64_t already_generated_coins,
|
const cryptonote::account_base& miner_acc, uint64_t timestamp, uint64_t already_generated_coins,
|
||||||
@ -251,7 +252,7 @@ public:
|
|||||||
uint8_t minor_ver = 0, uint64_t timestamp = 0, const crypto::hash& prev_id = crypto::hash(),
|
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 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,
|
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);
|
uint8_t hf_version = 1, uint64_t fees = 0);
|
||||||
bool construct_block_manually_tx(cryptonote::block& blk, const cryptonote::block& prev_block,
|
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);
|
const cryptonote::account_base& miner_acc, const std::vector<crypto::hash>& tx_hashes, size_t txs_size);
|
||||||
void fill_nonce(cryptonote::block& blk, const cryptonote::difficulty_type& diffic, uint64_t height);
|
void fill_nonce(cryptonote::block& blk, const cryptonote::difficulty_type& diffic, uint64_t height);
|
||||||
|
@ -175,7 +175,7 @@ bool gen_rct2_tx_validation_base::generate_with(std::vector<test_event_entry>& e
|
|||||||
CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk_txes, blk_last, miner_account,
|
CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk_txes, blk_last, miner_account,
|
||||||
test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_tx_hashes | test_generator::bf_hf_version | test_generator::bf_max_outs,
|
test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_tx_hashes | test_generator::bf_hf_version | test_generator::bf_max_outs,
|
||||||
hf_version, hf_version, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long
|
hf_version, hf_version, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long
|
||||||
crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 6, 10),
|
crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 6, hf_version),
|
||||||
false, "Failed to generate block");
|
false, "Failed to generate block");
|
||||||
if (!valid)
|
if (!valid)
|
||||||
DO_CALLBACK(events, "mark_invalid_block");
|
DO_CALLBACK(events, "mark_invalid_block");
|
||||||
|
Loading…
Reference in New Issue
Block a user