From a159bed3ba928fcdb8567bc912f8cd3adc9adc19 Mon Sep 17 00:00:00 2001 From: akildemir Date: Fri, 8 Aug 2025 14:54:55 +0300 Subject: [PATCH] remove tools::add_element --- src/carrot_core/output_set_finalization.cpp | 6 +- src/carrot_impl/format_utils.cpp | 3 +- src/common/container_helpers.h | 7 -- src/wallet/scanning_tools.cpp | 5 +- src/wallet/wallet2.cpp | 2 +- tests/unit_tests/carrot_impl.cpp | 101 ++++++++++---------- tests/unit_tests/x25519.cpp | 4 +- 7 files changed, 59 insertions(+), 69 deletions(-) diff --git a/src/carrot_core/output_set_finalization.cpp b/src/carrot_core/output_set_finalization.cpp index 3c0b4b6..c72f455 100644 --- a/src/carrot_core/output_set_finalization.cpp +++ b/src/carrot_core/output_set_finalization.cpp @@ -216,7 +216,7 @@ void get_output_enote_proposals(const std::vector &norm // construct normal enotes for (size_t i = 0; i < normal_payment_proposals.size(); ++i) { - auto &output_entry = tools::add_element(sortable_data); + auto &output_entry = sortable_data.emplace_back(); output_entry.second = {false, i}; encrypted_payment_id_t encrypted_payment_id; @@ -270,7 +270,7 @@ void get_output_enote_proposals(const std::vector &norm { const CarrotPaymentProposalSelfSendV1 &selfsend_payment_proposal = selfsend_payment_proposals.at(i); - auto &output_entry = tools::add_element(sortable_data); + auto &output_entry = sortable_data.emplace_back(); output_entry.second = {true, i}; if (s_view_balance_dev != nullptr) @@ -416,7 +416,7 @@ void get_coinbase_output_enotes(const std::vector &norm { get_coinbase_output_proposal_v1(normal_payment_proposals[i], block_index, - tools::add_element(output_coinbase_enotes_out)); + output_coinbase_enotes_out.emplace_back()); } // assert uniqueness and non-trivial-ness of D_e diff --git a/src/carrot_impl/format_utils.cpp b/src/carrot_impl/format_utils.cpp index ab980b8..b97ed6c 100644 --- a/src/carrot_impl/format_utils.cpp +++ b/src/carrot_impl/format_utils.cpp @@ -33,7 +33,6 @@ #include "carrot_core/enote_utils.h" #include "carrot_core/exceptions.h" #include "carrot_core/payment_proposal.h" -#include "common/container_helpers.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "cryptonote_core/cryptonote_tx_utils.h" #include "cryptonote_config.h" @@ -258,7 +257,7 @@ cryptonote::transaction store_carrot_to_transaction_v1(const std::vector &map, Pre return true; } -/// convenience wrapper for getting the last element after emplacing back -template -typename ContainerT::value_type& add_element(ContainerT &container) -{ - container.emplace_back(); - return container.back(); -} /// convenience erasor for unordered maps: std::erase_if(std::unordered_map) is C++20 template void for_all_in_map_erase_if(std::unordered_map &map_inout, PredT predicate) diff --git a/src/wallet/scanning_tools.cpp b/src/wallet/scanning_tools.cpp index beed81e..c181337 100644 --- a/src/wallet/scanning_tools.cpp +++ b/src/wallet/scanning_tools.cpp @@ -36,7 +36,6 @@ #include "carrot_core/lazy_amount_commitment.h" #include "carrot_core/scan.h" #include "carrot_impl/format_utils.h" -#include "common/container_helpers.h" #include "crypto/generators.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "ringct/rctOps.h" @@ -487,14 +486,14 @@ void perform_ecdh_derivations(const epee::span main_tx { hwdev.generate_key_derivation(main_tx_ephemeral_pubkey, k_view_incoming, - tools::add_element(main_derivations_out)); + main_derivations_out.emplace_back()); } for (const crypto::public_key &additional_tx_ephemeral_pubkey : additional_tx_ephemeral_pubkeys) { hwdev.generate_key_derivation(additional_tx_ephemeral_pubkey, k_view_incoming, - tools::add_element(additional_derivations_out)); + additional_derivations_out.emplace_back()); } } } diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index a152478..a7ca42f 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2621,7 +2621,7 @@ void wallet2::process_new_scanned_transaction( continue; // update m_transfers view-incoming scan info, and default values - transfer_details& td = tools::add_element(m_transfers); + transfer_details& td = m_transfers.emplace_back(); td.m_block_height = height; td.m_internal_output_index = local_output_index; td.m_global_output_index = o_indices.at(local_output_index); diff --git a/tests/unit_tests/carrot_impl.cpp b/tests/unit_tests/carrot_impl.cpp index ae2eb31..b5c52bf 100644 --- a/tests/unit_tests/carrot_impl.cpp +++ b/tests/unit_tests/carrot_impl.cpp @@ -38,7 +38,6 @@ #include "carrot_impl/tx_proposal_utils.h" #include "carrot_impl/input_selection.h" #include "carrot_mock_helpers.h" -#include "common/container_helpers.h" #include "crypto/generators.h" #include "cryptonote_basic/account.h" #include "cryptonote_basic/subaddress_index.h" @@ -63,7 +62,7 @@ static void unittest_scan_enote_set_multi_account(const std::vector(1000000), .randomness = gen_janus_anchor() }; // 1 main address payment - tools::add_element(acc1.second).first = CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }; // 1 integrated address payment - tools::add_element(acc3.second).first = CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -445,7 +444,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_3) tx_proposal.self_sender_index = 2; // 2 subaddress payment - tools::add_element(acc0.second).first = CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -454,7 +453,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_3) acc0.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 2 main address payment - tools::add_element(acc1.second).first = CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -463,7 +462,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_3) acc1.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 1 integrated address payment - tools::add_element(acc3.second).first = CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -498,7 +497,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_4) tx_proposal.self_sender_index = 2; // 2 subaddress payment - tools::add_element(acc0.second).first = CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -507,7 +506,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_4) acc0.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 2 main address payment - tools::add_element(acc1.second).first = CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -516,14 +515,14 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_4) acc1.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 1 integrated address payment - tools::add_element(acc3.second).first = CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }; // 1 main address selfsend - tools::add_element(tx_proposal.explicit_selfsend_proposals).first.proposal = CarrotPaymentProposalSelfSendV1{ + tx_proposal.explicit_selfsend_proposals.emplace_back().first.proposal = CarrotPaymentProposalSelfSendV1{ .destination_address_spend_pubkey = acc2.first.carrot_account_spend_pubkey, .amount = crypto::rand_idx(1000000), .enote_type = CarrotEnoteType::PAYMENT, @@ -531,7 +530,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_4) }; // 1 subaddress selfsend - tools::add_element(tx_proposal.explicit_selfsend_proposals).first = CarrotPaymentProposalVerifiableSelfSendV1{ + tx_proposal.explicit_selfsend_proposals.emplace_back().first = CarrotPaymentProposalVerifiableSelfSendV1{ .proposal = CarrotPaymentProposalSelfSendV1{ .destination_address_spend_pubkey = acc2.first.subaddress({{4, 19}}).address_spend_pubkey, .amount = crypto::rand_idx(1000000), @@ -562,7 +561,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_5) acc1.generate(AddressDeriveType::PreCarrot); // 1 normal payment - CarrotPaymentProposalV1 &normal_payment_proposal = tools::add_element( tx_proposal.per_account_payments[0].second).first; + CarrotPaymentProposalV1 &normal_payment_proposal = tx_proposal.per_account_payments[0].second.emplace_back().first; normal_payment_proposal = CarrotPaymentProposalV1{ .destination = acc0.cryptonote_address(), .amount = crypto::rand_idx((rct::xmr_amount) 1ull << 63), @@ -601,21 +600,21 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_6) tx_proposal.self_sender_index = 2; // 1 subaddress payment - tools::add_element(acc0.second).first = CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }; // 1 main address payment - tools::add_element(acc1.second).first = CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }; // 1 integrated address payment - tools::add_element(acc3.second).first = CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -650,7 +649,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_7) tx_proposal.self_sender_index = 2; // 2 subaddress payment - tools::add_element(acc0.second).first = CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -659,7 +658,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_7) acc0.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 2 main address payment - tools::add_element(acc1.second).first = CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -668,7 +667,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_7) acc1.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 1 integrated address payment - tools::add_element(acc3.second).first = CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -703,7 +702,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_8) tx_proposal.self_sender_index = 2; // 2 subaddress payment - tools::add_element(acc0.second).first = CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -712,7 +711,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_8) acc0.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 2 main address payment - tools::add_element(acc1.second).first = CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -721,14 +720,14 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_8) acc1.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 1 integrated address payment - tools::add_element(acc3.second).first = CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }; // 1 main address selfsend - tools::add_element(tx_proposal.explicit_selfsend_proposals).first.proposal = CarrotPaymentProposalSelfSendV1{ + tx_proposal.explicit_selfsend_proposals.emplace_back().first.proposal = CarrotPaymentProposalSelfSendV1{ .destination_address_spend_pubkey = acc2.first.carrot_account_spend_pubkey, .amount = crypto::rand_idx(1000000), .enote_type = CarrotEnoteType::PAYMENT, @@ -736,7 +735,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_8) }; // 1 subaddress selfsend - tools::add_element(tx_proposal.explicit_selfsend_proposals).first = CarrotPaymentProposalVerifiableSelfSendV1{ + tx_proposal.explicit_selfsend_proposals.emplace_back().first = CarrotPaymentProposalVerifiableSelfSendV1{ .proposal = CarrotPaymentProposalSelfSendV1{ .destination_address_spend_pubkey = acc2.first.subaddress({{4, 19}}).address_spend_pubkey, .amount = crypto::rand_idx(1000000), @@ -768,7 +767,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_9) acc1.generate(); // 1 normal payment (subtractable) - CarrotPaymentProposalV1 &normal_payment_proposal = tools::add_element( tx_proposal.per_account_payments[0].second).first; + CarrotPaymentProposalV1 &normal_payment_proposal = tx_proposal.per_account_payments[0].second.emplace_back().first; normal_payment_proposal = CarrotPaymentProposalV1{ .destination = acc0.cryptonote_address(), .amount = crypto::rand_idx((rct::xmr_amount) 1ull << 63), @@ -809,21 +808,21 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_10) tx_proposal.self_sender_index = 2; // 1 subaddress payment (subtractable) - tools::add_element(acc0.second) = {CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ = {CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }, true}; // 1 main address payment - tools::add_element(acc1.second).first = CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }; // 1 integrated address payment - tools::add_element(acc3.second) = {CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -859,7 +858,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_11) tx_proposal.self_sender_index = 2; // 2 subaddress payment - tools::add_element(acc0.second).first = CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -869,7 +868,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_11) acc0.second.back().second = true; //set copy as subtractable // 2 main address payment - tools::add_element(acc1.second).first = CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -879,7 +878,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_11) acc1.second.back().second = true; //set copy as subtractable // 1 integrated address payment - tools::add_element(acc3.second).first = CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -915,7 +914,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_12) tx_proposal.self_sender_index = 2; // 2 subaddress payment (1 subtractable) - tools::add_element(acc0.second) = {CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ = {CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -925,7 +924,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_12) acc0.second.back().second = false; //set not subtractable, first already is // 2 main address payment - tools::add_element(acc1.second).first = CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -934,14 +933,14 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_12) acc1.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 1 integrated address payment (subtractable) - tools::add_element(acc3.second) = {CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }, true}; // 1 main address selfsend - tools::add_element(tx_proposal.explicit_selfsend_proposals).first.proposal = CarrotPaymentProposalSelfSendV1{ + tx_proposal.explicit_selfsend_proposals.emplace_back().first.proposal = CarrotPaymentProposalSelfSendV1{ .destination_address_spend_pubkey = acc2.first.carrot_account_spend_pubkey, .amount = crypto::rand_idx(1000000), .enote_type = CarrotEnoteType::PAYMENT, @@ -949,7 +948,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_12) }; // 1 subaddress selfsend (subtractable) - tools::add_element(tx_proposal.explicit_selfsend_proposals) = {CarrotPaymentProposalVerifiableSelfSendV1{ + tx_proposal.explicit_selfsend_proposals.emplace_back().first = CarrotPaymentProposalVerifiableSelfSendV1{ .proposal = CarrotPaymentProposalSelfSendV1{ .destination_address_spend_pubkey = acc2.first.subaddress({{4, 19}}).address_spend_pubkey, .amount = crypto::rand_idx(1000000), @@ -981,7 +980,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_13) acc1.generate(AddressDeriveType::PreCarrot); // 1 normal payment (subtractable) - CarrotPaymentProposalV1 &normal_payment_proposal = tools::add_element( tx_proposal.per_account_payments[0].second).first; + CarrotPaymentProposalV1 &normal_payment_proposal = tx_proposal.per_account_payments[0].second.emplace_back().first; normal_payment_proposal = CarrotPaymentProposalV1{ .destination = acc0.cryptonote_address(), .amount = crypto::rand_idx((rct::xmr_amount) 1ull << 63), @@ -1022,21 +1021,21 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_14) tx_proposal.self_sender_index = 2; // 1 subaddress payment (subtractable) - tools::add_element(acc0.second) = {CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ = {CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }, true}; // 1 main address payment - tools::add_element(acc1.second).first = CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }; // 1 integrated address payment (subtractable) - tools::add_element(acc3.second) = {CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -1072,7 +1071,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_15) tx_proposal.self_sender_index = 2; // 2 subaddress payment (subtractable) - tools::add_element(acc0.second) = {CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ = {CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -1081,7 +1080,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_15) acc0.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 2 main address payment (subtractable) - tools::add_element(acc1.second) = {CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -1090,7 +1089,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_15) acc1.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 1 integrated address payment (subtractable) - tools::add_element(acc3.second) = {CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -1126,7 +1125,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_16) tx_proposal.self_sender_index = 2; // 2 subaddress payment (subtractable) - tools::add_element(acc0.second) = {CarrotPaymentProposalV1{ + acc0.second.emplace_back().first = CarrotPaymentProposalV1{ = {CarrotPaymentProposalV1{ .destination = acc0.first.subaddress({{2, 3}}), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -1135,7 +1134,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_16) acc0.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 2 main address payment (subtractable) - tools::add_element(acc1.second) = {CarrotPaymentProposalV1{ + acc1.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc1.first.cryptonote_address(), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() @@ -1144,22 +1143,22 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_16) acc1.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm // 1 integrated address payment (subtractable) - tools::add_element(acc3.second) = {CarrotPaymentProposalV1{ + acc3.second.emplace_back().first = CarrotPaymentProposalV1{ .destination = acc3.first.cryptonote_address(gen_payment_id()), .amount = crypto::rand_idx(1000000), .randomness = gen_janus_anchor() }, true}; // 1 main address selfsend (subtractable) - tools::add_element(tx_proposal.explicit_selfsend_proposals) = {{CarrotPaymentProposalSelfSendV1{ + tx_proposal.explicit_selfsend_proposals.emplace_back() = {CarrotPaymentProposalSelfSendV1{ .destination_address_spend_pubkey = acc2.first.carrot_account_spend_pubkey, .amount = crypto::rand_idx(1000000), .enote_type = CarrotEnoteType::PAYMENT, // no internal messages for legacy self-sends - }}, true}; + }, true}; // 1 subaddress selfsend (subtractable) - tools::add_element(tx_proposal.explicit_selfsend_proposals) = {CarrotPaymentProposalVerifiableSelfSendV1{ + tx_proposal.explicit_selfsend_proposals.emplace_back() = {CarrotPaymentProposalVerifiableSelfSendV1{ .proposal = CarrotPaymentProposalSelfSendV1{ .destination_address_spend_pubkey = acc2.first.subaddress({{4, 19}}).address_spend_pubkey, .amount = crypto::rand_idx(1000000), diff --git a/tests/unit_tests/x25519.cpp b/tests/unit_tests/x25519.cpp index 0505591..63feccc 100644 --- a/tests/unit_tests/x25519.cpp +++ b/tests/unit_tests/x25519.cpp @@ -157,7 +157,7 @@ TEST(x25519, scmul_key_convergence) for (unsigned char j = 0; j < 8; ++j) { // add 2^i + j (sometimes with duplicates, which is okay) - mx25519_privkey &s = tools::add_element(scalars); + mx25519_privkey &s = scalars.emplace_back(); memset(s.data, 0, sizeof(mx25519_privkey)); const int msb_byte_index = i >> 3; const int msb_bit_index = i & 7; @@ -169,7 +169,7 @@ TEST(x25519, scmul_key_convergence) scalars.push_back(hex2pod("ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f")); // add random const rct::key a = rct::skGen(); - memcpy(tools::add_element(scalars).data, &a, sizeof(mx25519_privkey)); + memcpy(scalars.emplace_back().data, &a, sizeof(mx25519_privkey)); std::vector> points; // add base point