From 146bf5102197852587343759f9d6b2b2369507d2 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 18 Oct 2023 21:08:16 +0200 Subject: [PATCH] chaingen: balance_via_wallet() now supports asset id, replace_coinbase_in_genesis_block() fixed --- tests/core_tests/chaingen.cpp | 34 ++++++++++++++++++++++++---------- tests/core_tests/chaingen.h | 5 +++-- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index 2f0aac77..b16e24ee 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -1905,10 +1905,10 @@ bool find_block_chain(const std::vector& events, std::vector& sources) return true; } +// creates destinations.size() + 1 outputs if the total sum of amounts is less than the original premine amount (the last one will have amount = old_premine - sum) bool replace_coinbase_in_genesis_block(const std::vector& destinations, test_generator& generator, std::vector& events, currency::block& genesis_block) { bool r = false; @@ -2340,13 +2345,19 @@ bool replace_coinbase_in_genesis_block(const std::vectortype() == typeid(crypto::public_key)) { - boost::get(el) = tx_key.pub; - break; + boost::get(*it) = tx_key.pub; // rewtire it } + else if (it->type() == typeid(tx_derivation_hint)) + { + it = genesis_block.miner_tx.extra.erase(it); + continue; // remove it + } + + ++it; } uint64_t total_amount = 0; @@ -2357,10 +2368,13 @@ bool replace_coinbase_in_genesis_block(const std::vector& event bool use_ref_by_id = false); uint64_t get_balance(const currency::account_keys& addr, const std::vector& blockchain, const map_hash2tx_t& mtx, bool dbg_log = false); uint64_t get_balance(const currency::account_base& addr, const std::vector& blockchain, const map_hash2tx_t& mtx, bool dbg_log = false); -void balance_via_wallet(const tools::wallet2& w, uint64_t* p_total, uint64_t* p_unlocked = 0, uint64_t* p_awaiting_in = 0, uint64_t* p_awaiting_out = 0, uint64_t* p_mined = 0); +void balance_via_wallet(const tools::wallet2& w, const crypto::public_key& asset_id, uint64_t* p_total, uint64_t* p_unlocked = 0, uint64_t* p_awaiting_in = 0, uint64_t* p_awaiting_out = 0, uint64_t* p_mined = 0); #define INVALID_BALANCE_VAL std::numeric_limits::max() bool check_balance_via_wallet(const tools::wallet2& w, const char* account_name, uint64_t expected_total, uint64_t expected_mined = INVALID_BALANCE_VAL, uint64_t expected_unlocked = INVALID_BALANCE_VAL, uint64_t expected_awaiting_in = INVALID_BALANCE_VAL, - uint64_t expected_awaiting_out = INVALID_BALANCE_VAL); + uint64_t expected_awaiting_out = INVALID_BALANCE_VAL, + const crypto::public_key& asset_id = currency::native_coin_asset_id); bool calculate_amounts_many_outs_have_and_no_outs_have(const uint64_t first_blocks_reward, uint64_t& amount_many_outs_have, uint64_t& amount_no_outs_have); bool find_global_index_for_output(const std::vector& events, const crypto::hash& head_block_hash, const currency::transaction& reference_tx, const size_t reference_tx_out_index, uint64_t& global_index);