aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-08-28 18:06:23 -0500
committerluigi1111 <luigi1111w@gmail.com>2020-08-28 18:06:23 -0500
commit51bf6b5842d488ee02a75f7e6296f7345b5a1060 (patch)
treebaf49c46bd7dd3c240c3015a8f43b2cfb38f6ec3
parentMerge pull request #6769 (diff)
parentcore_tests: fix failures after v13 (diff)
downloadmonero-51bf6b5842d488ee02a75f7e6296f7345b5a1060.tar.xz
Merge pull request #6785
4a9bd8f core_tests: remove hardcoded hf version (monermooo-monero) 1dc427d core_tests: fix failures after v13 (moneromooo-monero)
-rw-r--r--tests/core_tests/bulletproofs.cpp9
-rw-r--r--tests/core_tests/chaingen.cpp16
-rw-r--r--tests/core_tests/chaingen.h7
-rw-r--r--tests/core_tests/rct2.cpp2
4 files changed, 21 insertions, 13 deletions
diff --git a/tests/core_tests/bulletproofs.cpp b/tests/core_tests/bulletproofs.cpp
index 44adc42e7..c46b5e657 100644
--- a/tests/core_tests/bulletproofs.cpp
+++ b/tests/core_tests/bulletproofs.cpp
@@ -87,6 +87,7 @@ bool gen_bp_tx_validation_base::generate_with(std::vector<test_event_entry>& eve
std::vector<transaction> rct_txes;
cryptonote::block blk_txes;
std::vector<crypto::hash> starting_rct_tx_hashes;
+ uint64_t fees = 0;
static const uint64_t input_amounts_available[] = {5000000000000, 30000000000000, 100000000000, 80000000000};
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)
++amounts_paid;
++amounts_paid;
+
+ uint64_t fee = 0;
+ get_tx_fee(rct_txes.back(), fee);
+ fees += fee;
}
if (!valid)
DO_CALLBACK(events, "mark_invalid_tx");
events.push_back(rct_txes);
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
- 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");
if (!valid)
DO_CALLBACK(events, "mark_invalid_block");
diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp
index f442a4977..e8f070214 100644
--- a/tests/core_tests/chaingen.cpp
+++ b/tests/core_tests/chaingen.cpp
@@ -226,11 +226,9 @@ uint64_t test_generator::get_already_generated_coins(const cryptonote::block& bl
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);
- 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);
}
@@ -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);
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;
}
@@ -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 transaction& miner_tx/* = transaction()*/,
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.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>();
max_outs = actual_params & bf_max_outs ? max_outs : 9999;
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;
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);
// 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;
}
@@ -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);
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;
}
diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h
index 8b6135510..a5fd35028 100644
--- a/tests/core_tests/chaingen.h
+++ b/tests/core_tests/chaingen.h
@@ -225,7 +225,8 @@ public:
bf_tx_hashes = 1 << 5,
bf_diffic = 1 << 6,
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) {}
@@ -235,7 +236,7 @@ public:
uint64_t get_already_generated_coins(const crypto::hash& blk_id) 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);
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,
@@ -251,7 +252,7 @@ public:
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);
+ uint8_t hf_version = 1, uint64_t fees = 0);
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);
void fill_nonce(cryptonote::block& blk, const cryptonote::difficulty_type& diffic, uint64_t height);
diff --git a/tests/core_tests/rct2.cpp b/tests/core_tests/rct2.cpp
index 55d700429..8d7c4b3eb 100644
--- a/tests/core_tests/rct2.cpp
+++ b/tests/core_tests/rct2.cpp
@@ -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,
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
- 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");
if (!valid)
DO_CALLBACK(events, "mark_invalid_block");