1
0
Fork 0
forked from lthn/blockchain

core tests working

This commit is contained in:
cryptozoidberg 2024-09-02 21:44:41 +04:00
parent 77a928c78a
commit ca09405491
No known key found for this signature in database
GPG key ID: 2E10CC61CAC8F36D
6 changed files with 20 additions and 19 deletions

View file

@ -802,7 +802,7 @@ namespace tools
}
ptc.employed_entries.receive.push_back(wallet_public::employed_tx_entry{ o , out.amount , out.asset_id });
uint64_t new_index = m_transfers.empty() ? 0 : (--m_transfers.end())->first;
uint64_t new_index = m_transfers.empty() ? 0 : (--m_transfers.end())->first+1;
auto rsp = m_transfers.insert(std::make_pair(new_index, boost::value_initialized<transfer_details>()));
transfer_details& td = rsp.first->second;
td.m_ptx_wallet_info = pwallet_info;
@ -2995,11 +2995,11 @@ namespace tools
// rollback incoming transfers from detaching subchain
{
auto it = std::find_if(m_transfers.begin(), m_transfers.end(), [&](const transfer_container::value_type& tr_e){return tr_e.second.m_ptx_wallet_info->m_block_height >= including_height; });
if (it != m_transfers.end())
auto it_start = std::find_if(m_transfers.begin(), m_transfers.end(), [&](const transfer_container::value_type& tr_e){return tr_e.second.m_ptx_wallet_info->m_block_height >= including_height; });
if (it_start != m_transfers.end())
{
for (; it!= m_transfers.end(); it++)
for (auto it = it_start; it!= m_transfers.end(); it++)
{
uint64_t i = it->first;
//check for htlc
@ -3034,7 +3034,7 @@ namespace tools
remove_transfer_from_amount_gindex_map(i);
++transfers_detached;
}
m_transfers.erase(it, m_transfers.end());
m_transfers.erase(it_start, m_transfers.end());
}
}
@ -4458,10 +4458,10 @@ namespace tools
return m_transfer_history.size();
}
//----------------------------------------------------------------------------------------------------
//uint64_t wallet2::get_transfer_entries_count()
//{
// return m_transfers.size();
//}
uint64_t wallet2::get_transfer_entries_count()
{
return m_transfers.size();
}
//----------------------------------------------------------------------------------------------------
template<typename callback_t, typename iterator_t>

View file

@ -401,7 +401,7 @@ namespace tools
void get_recent_transfers_history(std::vector<wallet_public::wallet_transfer_info>& trs, size_t offset, size_t count, uint64_t& total, uint64_t& last_item_index, bool exclude_mining_txs = false, bool start_from_end = true);
bool is_defragmentation_transaction(const wallet_public::wallet_transfer_info& wti);
uint64_t get_recent_transfers_total_count();
//uint64_t get_transfer_entries_count();
uint64_t get_transfer_entries_count();
void get_unconfirmed_transfers(std::vector<wallet_public::wallet_transfer_info>& trs, bool exclude_mining_txs = false);
void init(const std::string& daemon_address = "http://localhost:8080");
bool deinit();

View file

@ -2172,12 +2172,13 @@ bool make_tx_multisig_to_key(const currency::transaction& source_tx,
bool estimate_wallet_balance_blocked_for_escrow(const tools::wallet2& w, uint64_t& result, bool substruct_change_from_result /* = true */)
{
std::deque<tools::transfer_details> transfers;
tools::transfer_container transfers;
w.get_transfers(transfers);
result = 0;
for (const tools::transfer_details& td : transfers)
for (const auto& tr : transfers)
{
const tools::transfer_details& td = tr.second;
if (td.m_flags == (WALLET_TRANSFER_DETAIL_FLAG_BLOCKED | WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION))
result += td.amount();
}

View file

@ -780,7 +780,7 @@ bool escrow_proposal_expiration::c1(currency::core& c, size_t ev_index, const st
uint64_t alice_post_proposal_balance = alice_wlt->balance();
uint64_t alice_post_proposal_balance_expected = alice_start_balance - TESTS_DEFAULT_FEE;
CHECK_AND_ASSERT_MES(alice_post_proposal_balance == alice_post_proposal_balance_expected, false, "Incorrect alice_post_proposal_balance: " << print_money(alice_post_proposal_balance) << ", expected: " << print_money(alice_post_proposal_balance_expected));
std::deque<tools::transfer_details> transfers;
tools::transfer_container transfers;
alice_wlt->get_transfers(transfers);
CHECK_AND_ASSERT_MES(transfers.size() == 2 && (
(transfers[0].is_spent() && (transfers[1].m_flags & (WALLET_TRANSFER_DETAIL_FLAG_BLOCKED | WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION))) ||
@ -2283,7 +2283,7 @@ bool escrow_proposal_not_enough_money::c1(currency::core& c, size_t ev_index, co
CHECK_AND_ASSERT_MES(check_balance_via_wallet(*alice_wlt.get(), "Alice", MK_TEST_COINS(30), 0, MK_TEST_COINS(30), 0, 0), false, "");
std::deque<tools::transfer_details> transfers;
tools::transfer_container transfers;
alice_wlt->get_transfers(transfers);
CHECK_AND_ASSERT_MES(transfers.size() == 1, false, "Incorrect transfers size: " << transfers.size());

View file

@ -533,7 +533,7 @@ bool assets_and_explicit_native_coins_in_outs::c2_alice_deploys_asset(currency::
// make sure Alice has two UTXO now
tools::transfer_container transfers{};
alice_wlt->get_transfers(transfers);
size_t unspent_transfers = std::count_if(transfers.begin(), transfers.end(), [](const tools::transfer_details& tr){ return !tr.is_spent(); });
size_t unspent_transfers = std::count_if(transfers.begin(), transfers.end(), [](const auto& tr){ return !tr.second.is_spent(); });
CHECK_AND_ASSERT_MES(unspent_transfers == 2, false, "unexpected number of Alice's unspent transfers: " << unspent_transfers);
asset_descriptor_base adb{};
@ -692,15 +692,15 @@ bool asset_depoyment_and_few_zc_utxos::c1(currency::core& c, size_t ev_index, co
CHECK_AND_ASSERT_MES(check_balance_via_wallet(*alice_wlt, "Alice", m_alice_initial_balance, 0, m_alice_initial_balance, 0, 0), false, "");
// make sure Alice has correct UTXO wallet structure
tools::transfer_container transfers{};
tools::transfer_container transfers;
alice_wlt->get_transfers(transfers);
size_t zc_unspent_outs = 0, unspent_outs = 0;
for(auto& td : transfers)
{
if (!td.is_spent())
if (!td.second.is_spent())
{
++unspent_outs;
if (td.is_zc())
if (td.second.is_zc())
++zc_unspent_outs;
}
}

View file

@ -2571,7 +2571,7 @@ bool multisig_unconfirmed_transfer_and_multiple_scan_pool_calls::c1(currency::co
LOG_PRINT_YELLOW("%%%%% tx " << get_transaction_hash(tx) << " is spending multisig output " << multisig_id, LOG_LEVEL_0);
bool stub;
std::deque<tools::transfer_details> transfers;
tools::transfer_container transfers;
std::vector<tools::wallet_public::wallet_transfer_info> unconfirmed_transfers;
alice_wlt->scan_tx_pool(stub);