aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/core_proxy/core_proxy.h1
-rw-r--r--tests/core_tests/chain_switch_1.cpp2
-rw-r--r--tests/core_tests/chaingen.cpp7
-rw-r--r--tests/core_tests/integer_overflow.cpp6
-rw-r--r--tests/core_tests/rct.cpp10
-rw-r--r--tests/core_tests/ring_signature_1.cpp3
-rw-r--r--tests/core_tests/transaction_tests.cpp10
-rw-r--r--tests/core_tests/tx_validation.cpp5
-rw-r--r--tests/crypto/main.cpp6
-rw-r--r--tests/functional_tests/transactions_flow_test.cpp8
-rw-r--r--tests/fuzz/signature.cpp5
-rw-r--r--tests/libwallet_api_tests/main.cpp114
-rw-r--r--tests/performance_tests/check_tx_signature.h7
-rw-r--r--tests/performance_tests/construct_tx.h7
-rw-r--r--tests/performance_tests/ge_frombytes_vartime.h2
-rw-r--r--tests/performance_tests/generate_key_image_helper.h5
-rw-r--r--tests/performance_tests/is_out_to_acc.h2
-rw-r--r--tests/performance_tests/single_tx_test_base.h2
-rw-r--r--tests/unit_tests/CMakeLists.txt1
-rw-r--r--tests/unit_tests/ban.cpp1
-rw-r--r--tests/unit_tests/base58.cpp32
-rw-r--r--tests/unit_tests/dns_resolver.cpp14
-rw-r--r--tests/unit_tests/hashchain.cpp2
-rw-r--r--tests/unit_tests/mnemonics.cpp4
-rw-r--r--tests/unit_tests/serialization.cpp20
-rw-r--r--tests/unit_tests/sha256.cpp45
26 files changed, 204 insertions, 117 deletions
diff --git a/tests/core_proxy/core_proxy.h b/tests/core_proxy/core_proxy.h
index cc35be618..51f0f892c 100644
--- a/tests/core_proxy/core_proxy.h
+++ b/tests/core_proxy/core_proxy.h
@@ -101,5 +101,6 @@ namespace tests
uint8_t get_hard_fork_version(uint64_t height) const { return 0; }
cryptonote::difficulty_type get_block_cumulative_difficulty(uint64_t height) const { return 0; }
bool fluffy_blocks_enabled() const { return false; }
+ uint64_t prevalidate_block_hashes(uint64_t height, const std::list<crypto::hash> &hashes) { return 0; }
};
}
diff --git a/tests/core_tests/chain_switch_1.cpp b/tests/core_tests/chain_switch_1.cpp
index a48105f49..b04d05219 100644
--- a/tests/core_tests/chain_switch_1.cpp
+++ b/tests/core_tests/chain_switch_1.cpp
@@ -152,7 +152,7 @@ bool gen_chain_switch_1::check_split_not_switched(cryptonote::core& c, size_t ev
std::vector<size_t> tx_outs;
uint64_t transfered;
- lookup_acc_outs(m_recipient_account_4.get_keys(), tx_pool.front(), get_tx_pub_key_from_extra(tx_pool.front()), tx_outs, transfered);
+ lookup_acc_outs(m_recipient_account_4.get_keys(), tx_pool.front(), get_tx_pub_key_from_extra(tx_pool.front()), get_additional_tx_pub_keys_from_extra(tx_pool.front()), tx_outs, transfered);
CHECK_EQ(MK_COINS(13), transfered);
m_chain_1.swap(blocks);
diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp
index b15487a24..f23aa8ecb 100644
--- a/tests/core_tests/chaingen.cpp
+++ b/tests/core_tests/chaingen.cpp
@@ -344,7 +344,7 @@ bool init_output_indices(map_output_idx_t& outs, std::map<uint64_t, std::vector<
size_t tx_global_idx = outs[out.amount].size() - 1;
outs[out.amount][tx_global_idx].idx = tx_global_idx;
// Is out to me?
- if (is_out_to_acc(from.get_keys(), boost::get<txout_to_key>(out.target), get_tx_pub_key_from_extra(tx), j)) {
+ if (is_out_to_acc(from.get_keys(), boost::get<txout_to_key>(out.target), get_tx_pub_key_from_extra(tx), get_additional_tx_pub_keys_from_extra(tx), j)) {
outs_mine[out.amount].push_back(tx_global_idx);
}
}
@@ -364,7 +364,10 @@ bool init_spent_output_indices(map_output_idx_t& outs, map_output_t& outs_mine,
// construct key image for this output
crypto::key_image img;
keypair in_ephemeral;
- generate_key_image_helper(from.get_keys(), get_tx_pub_key_from_extra(*oi.p_tx), oi.out_no, in_ephemeral, img);
+ crypto::public_key out_key = boost::get<txout_to_key>(oi.out).key;
+ std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
+ subaddresses[from.get_keys().m_account_address.m_spend_public_key] = {0,0};
+ generate_key_image_helper(from.get_keys(), subaddresses, out_key, get_tx_pub_key_from_extra(*oi.p_tx), get_additional_tx_pub_keys_from_extra(*oi.p_tx), oi.out_no, in_ephemeral, img);
// lookup for this key image in the events vector
BOOST_FOREACH(auto& tx_pair, mtx) {
diff --git a/tests/core_tests/integer_overflow.cpp b/tests/core_tests/integer_overflow.cpp
index 75f374434..3ac55c073 100644
--- a/tests/core_tests/integer_overflow.cpp
+++ b/tests/core_tests/integer_overflow.cpp
@@ -169,10 +169,10 @@ bool gen_uint_overflow_2::generate(std::vector<test_event_entry>& events) const
std::vector<cryptonote::tx_destination_entry> destinations;
const account_public_address& bob_addr = bob_account.get_keys().m_account_address;
- destinations.push_back(tx_destination_entry(MONEY_SUPPLY, bob_addr));
- destinations.push_back(tx_destination_entry(MONEY_SUPPLY - 1, bob_addr));
+ destinations.push_back(tx_destination_entry(MONEY_SUPPLY, bob_addr, false));
+ destinations.push_back(tx_destination_entry(MONEY_SUPPLY - 1, bob_addr, false));
// sources.front().amount = destinations[0].amount + destinations[2].amount + destinations[3].amount + TESTS_DEFAULT_FEE
- destinations.push_back(tx_destination_entry(sources.front().amount - MONEY_SUPPLY - MONEY_SUPPLY + 1 - TESTS_DEFAULT_FEE, bob_addr));
+ destinations.push_back(tx_destination_entry(sources.front().amount - MONEY_SUPPLY - MONEY_SUPPLY + 1 - TESTS_DEFAULT_FEE, bob_addr, false));
cryptonote::transaction tx_1;
if (!construct_tx(miner_account.get_keys(), sources, destinations, std::vector<uint8_t>(), tx_1, 0))
diff --git a/tests/core_tests/rct.cpp b/tests/core_tests/rct.cpp
index b546e4407..8a38cbc22 100644
--- a/tests/core_tests/rct.cpp
+++ b/tests/core_tests/rct.cpp
@@ -117,7 +117,10 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev
destinations.push_back(td); // 30 -> 7.39 * 4
crypto::secret_key tx_key;
- bool r = construct_tx_and_get_tx_key(miner_accounts[n].get_keys(), sources, destinations, std::vector<uint8_t>(), rct_txes[n], 0, tx_key, true);
+ std::vector<crypto::secret_key> additional_tx_keys;
+ std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
+ subaddresses[miner_accounts[n].get_keys().m_account_address.m_spend_public_key] = {0,0};
+ bool r = construct_tx_and_get_tx_key(miner_accounts[n].get_keys(), subaddresses, sources, destinations, cryptonote::account_public_address{}, std::vector<uint8_t>(), rct_txes[n], 0, tx_key, additional_tx_keys, true);
CHECK_AND_ASSERT_MES(r, false, "failed to construct transaction");
events.push_back(rct_txes[n]);
starting_rct_tx_hashes.push_back(get_transaction_hash(rct_txes[n]));
@@ -215,7 +218,10 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev
transaction tx;
crypto::secret_key tx_key;
- bool r = construct_tx_and_get_tx_key(miner_accounts[0].get_keys(), sources, destinations, std::vector<uint8_t>(), tx, 0, tx_key, true);
+ std::vector<crypto::secret_key> additional_tx_keys;
+ std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
+ subaddresses[miner_accounts[0].get_keys().m_account_address.m_spend_public_key] = {0,0};
+ bool r = construct_tx_and_get_tx_key(miner_accounts[0].get_keys(), subaddresses, sources, destinations, cryptonote::account_public_address{}, std::vector<uint8_t>(), tx, 0, tx_key, additional_tx_keys, true);
CHECK_AND_ASSERT_MES(r, false, "failed to construct transaction");
if (post_tx)
diff --git a/tests/core_tests/ring_signature_1.cpp b/tests/core_tests/ring_signature_1.cpp
index 997f3090d..f9ec68e45 100644
--- a/tests/core_tests/ring_signature_1.cpp
+++ b/tests/core_tests/ring_signature_1.cpp
@@ -337,7 +337,8 @@ bool gen_ring_signature_big::check_balances_2(cryptonote::core& c, size_t ev_ind
std::vector<size_t> tx_outs;
uint64_t transfered;
- lookup_acc_outs(m_alice_account.get_keys(), boost::get<transaction>(events[events.size() - 3]), get_tx_pub_key_from_extra(boost::get<transaction>(events[events.size() - 3])), tx_outs, transfered);
+ const transaction& tx = boost::get<transaction>(events[events.size() - 3]);
+ lookup_acc_outs(m_alice_account.get_keys(), boost::get<transaction>(events[events.size() - 3]), get_tx_pub_key_from_extra(tx), get_additional_tx_pub_keys_from_extra(tx), tx_outs, transfered);
CHECK_EQ(m_tx_amount, transfered);
return true;
diff --git a/tests/core_tests/transaction_tests.cpp b/tests/core_tests/transaction_tests.cpp
index 8c0d92a8f..dcba36e80 100644
--- a/tests/core_tests/transaction_tests.cpp
+++ b/tests/core_tests/transaction_tests.cpp
@@ -125,11 +125,11 @@ bool test_transaction_generation_and_ring_signature()
std::vector<size_t> outs;
uint64_t money = 0;
- r = lookup_acc_outs(rv_acc.get_keys(), tx_rc1, get_tx_pub_key_from_extra(tx_rc1), outs, money);
+ r = lookup_acc_outs(rv_acc.get_keys(), tx_rc1, get_tx_pub_key_from_extra(tx_rc1), get_additional_tx_pub_keys_from_extra(tx_rc1), outs, money);
CHECK_AND_ASSERT_MES(r, false, "failed to lookup_acc_outs");
CHECK_AND_ASSERT_MES(td.amount == money, false, "wrong money amount in new transaction");
money = 0;
- r = lookup_acc_outs(rv_acc2.get_keys(), tx_rc1, get_tx_pub_key_from_extra(tx_rc1), outs, money);
+ r = lookup_acc_outs(rv_acc2.get_keys(), tx_rc1, get_tx_pub_key_from_extra(tx_rc1), get_additional_tx_pub_keys_from_extra(tx_rc1), outs, money);
CHECK_AND_ASSERT_MES(r, false, "failed to lookup_acc_outs");
CHECK_AND_ASSERT_MES(0 == money, false, "wrong money amount in new transaction");
return true;
@@ -139,11 +139,11 @@ bool test_block_creation()
{
uint64_t vszs[] = {80,476,476,475,475,474,475,474,474,475,472,476,476,475,475,474,475,474,474,475,472,476,476,475,475,474,475,474,474,475,9391,476,476,475,475,474,475,8819,8301,475,472,4302,5316,14347,16620,19583,19403,19728,19442,19852,19015,19000,19016,19795,19749,18087,19787,19704,19750,19267,19006,19050,19445,19407,19522,19546,19788,19369,19486,19329,19370,18853,19600,19110,19320,19746,19474,19474,19743,19494,19755,19715,19769,19620,19368,19839,19532,23424,28287,30707};
std::vector<uint64_t> szs(&vszs[0], &vszs[90]);
- account_public_address adr;
- bool r = get_account_address_from_str(adr, false, "0099be99c70ef10fd534c43c88e9d13d1c8853213df7e362afbec0e4ee6fec4948d0c190b58f4b356cd7feaf8d9d0a76e7c7e5a9a0a497a6b1faf7a765882dd08ac2");
+ address_parse_info info;
+ bool r = get_account_address_from_str(info, false, "0099be99c70ef10fd534c43c88e9d13d1c8853213df7e362afbec0e4ee6fec4948d0c190b58f4b356cd7feaf8d9d0a76e7c7e5a9a0a497a6b1faf7a765882dd08ac2");
CHECK_AND_ASSERT_MES(r, false, "failed to import");
block b;
- r = construct_miner_tx(90, epee::misc_utils::median(szs), 3553616528562147, 33094, 10000000, adr, b.miner_tx, blobdata(), 11);
+ r = construct_miner_tx(90, epee::misc_utils::median(szs), 3553616528562147, 33094, 10000000, info.address, b.miner_tx, blobdata(), 11);
return r;
}
diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp
index 66460e876..0e4b2e71a 100644
--- a/tests/core_tests/tx_validation.cpp
+++ b/tests/core_tests/tx_validation.cpp
@@ -59,7 +59,10 @@ namespace
m_in_contexts.push_back(keypair());
keypair& in_ephemeral = m_in_contexts.back();
crypto::key_image img;
- generate_key_image_helper(sender_account_keys, src_entr.real_out_tx_key, src_entr.real_output_in_tx_index, in_ephemeral, img);
+ std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
+ subaddresses[sender_account_keys.m_account_address.m_spend_public_key] = {0,0};
+ auto& out_key = reinterpret_cast<const crypto::public_key&>(src_entr.outputs[src_entr.real_output].second.dest);
+ generate_key_image_helper(sender_account_keys, subaddresses, out_key, src_entr.real_out_tx_key, src_entr.real_out_additional_tx_keys, src_entr.real_output_in_tx_index, in_ephemeral, img);
// put key image into tx input
txin_to_key input_to_key;
diff --git a/tests/crypto/main.cpp b/tests/crypto/main.cpp
index 4264409b5..0fc8aba59 100644
--- a/tests/crypto/main.cpp
+++ b/tests/crypto/main.cpp
@@ -52,10 +52,6 @@ bool operator !=(const ec_point &a, const ec_point &b) {
return 0 != memcmp(&a, &b, sizeof(ec_point));
}
-bool operator !=(const secret_key &a, const secret_key &b) {
- return 0 != memcmp(&a, &b, sizeof(secret_key));
-}
-
bool operator !=(const key_derivation &a, const key_derivation &b) {
return 0 != memcmp(&a, &b, sizeof(key_derivation));
}
@@ -99,7 +95,7 @@ int main(int argc, char *argv[]) {
vector<char> data;
ec_scalar expected, actual;
get(input, data, expected);
- hash_to_scalar(data.data(), data.size(), actual);
+ crypto::hash_to_scalar(data.data(), data.size(), actual);
if (expected != actual) {
goto error;
}
diff --git a/tests/functional_tests/transactions_flow_test.cpp b/tests/functional_tests/transactions_flow_test.cpp
index 48e7b5ab6..d39b1b2e8 100644
--- a/tests/functional_tests/transactions_flow_test.cpp
+++ b/tests/functional_tests/transactions_flow_test.cpp
@@ -172,7 +172,7 @@ bool transactions_flow_test(std::string& working_folder,
//wait for money, until balance will have enough money
w1.refresh(blocks_fetched, received_money, ok);
- while(w1.unlocked_balance() < amount_to_transfer)
+ while(w1.unlocked_balance(0) < amount_to_transfer)
{
misc_utils::sleep_no_w(1000);
w1.refresh(blocks_fetched, received_money, ok);
@@ -185,7 +185,7 @@ bool transactions_flow_test(std::string& working_folder,
{
tools::wallet2::transfer_container incoming_transfers;
w1.get_transfers(incoming_transfers);
- if(incoming_transfers.size() > FIRST_N_TRANSFERS && get_money_in_first_transfers(incoming_transfers, FIRST_N_TRANSFERS) < w1.unlocked_balance() )
+ if(incoming_transfers.size() > FIRST_N_TRANSFERS && get_money_in_first_transfers(incoming_transfers, FIRST_N_TRANSFERS) < w1.unlocked_balance(0) )
{
//lets go!
size_t count = 0;
@@ -220,7 +220,7 @@ bool transactions_flow_test(std::string& working_folder,
for(i = 0; i != transactions_count; i++)
{
uint64_t amount_to_tx = (amount_to_transfer - transfered_money) > transfer_size ? transfer_size: (amount_to_transfer - transfered_money);
- while(w1.unlocked_balance() < amount_to_tx + TEST_FEE)
+ while(w1.unlocked_balance(0) < amount_to_tx + TEST_FEE)
{
misc_utils::sleep_no_w(1000);
LOG_PRINT_L0("not enough money, waiting for cashback or mining");
@@ -269,7 +269,7 @@ bool transactions_flow_test(std::string& working_folder,
misc_utils::sleep_no_w(DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN*1000);//wait two blocks before sync on another wallet on another daemon
}
- uint64_t money_2 = w2.balance();
+ uint64_t money_2 = w2.balance(0);
if(money_2 == transfered_money)
{
MGINFO_GREEN("-----------------------FINISHING TRANSACTIONS FLOW TEST OK-----------------------");
diff --git a/tests/fuzz/signature.cpp b/tests/fuzz/signature.cpp
index 69d0ad25b..071297ba8 100644
--- a/tests/fuzz/signature.cpp
+++ b/tests/fuzz/signature.cpp
@@ -66,9 +66,8 @@ int SignatureFuzzer::init()
boost::filesystem::remove("/tmp/signature-test.address.txt");
boost::filesystem::remove("/tmp/signature-test");
- bool has_payment_id;
- crypto::hash8 new_payment_id;
- if (!cryptonote::get_account_address_from_str_or_url(address, has_payment_id, new_payment_id, true, "9uVsvEryzpN8WH2t1WWhFFCG5tS8cBNdmJYNRuckLENFimfauV5pZKeS1P2CbxGkSDTUPHXWwiYE5ZGSXDAGbaZgDxobqDN"))
+ cryptonote::address_parse_info info;
+ if (!cryptonote::get_account_address_from_str_or_url(info, true, "9uVsvEryzpN8WH2t1WWhFFCG5tS8cBNdmJYNRuckLENFimfauV5pZKeS1P2CbxGkSDTUPHXWwiYE5ZGSXDAGbaZgDxobqDN"))
{
std::cerr << "failed to parse address" << std::endl;
return 1;
diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp
index d08ab7c75..a3cf227de 100644
--- a/tests/libwallet_api_tests/main.cpp
+++ b/tests/libwallet_api_tests/main.cpp
@@ -130,7 +130,7 @@ struct Utils
{
Monero::WalletManager *wmgr = Monero::WalletManagerFactory::getWalletManager();
Monero::Wallet * w = wmgr->openWallet(filename, password, true);
- std::string result = w->address();
+ std::string result = w->mainAddress();
wmgr->closeWallet(w);
return result;
}
@@ -215,8 +215,8 @@ TEST_F(WalletManagerTest, WalletManagerCreatesWallet)
boost::split(words, seed, boost::is_any_of(" "), boost::token_compress_on);
ASSERT_TRUE(words.size() == 25);
std::cout << "** seed: " << wallet->seed() << std::endl;
- ASSERT_FALSE(wallet->address().empty());
- std::cout << "** address: " << wallet->address() << std::endl;
+ ASSERT_FALSE(wallet->mainAddress().empty());
+ std::cout << "** address: " << wallet->mainAddress() << std::endl;
ASSERT_TRUE(wmgr->closeWallet(wallet));
}
@@ -261,7 +261,7 @@ void open_wallet_helper(Monero::WalletManager *wmgr, Monero::Wallet **wallet, co
mutex->lock();
LOG_PRINT_L3("opening wallet in thread: " << boost::this_thread::get_id());
*wallet = wmgr->openWallet(WALLET_NAME, pass, true);
- LOG_PRINT_L3("wallet address: " << (*wallet)->address());
+ LOG_PRINT_L3("wallet address: " << (*wallet)->mainAddress());
LOG_PRINT_L3("wallet status: " << (*wallet)->status());
LOG_PRINT_L3("closing wallet in thread: " << boost::this_thread::get_id());
if (mutex)
@@ -371,14 +371,14 @@ TEST_F(WalletManagerTest, WalletManagerRecoversWallet)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
std::string seed1 = wallet1->seed();
- std::string address1 = wallet1->address();
+ std::string address1 = wallet1->mainAddress();
ASSERT_FALSE(address1.empty());
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Utils::deleteWallet(WALLET_NAME);
Monero::Wallet * wallet2 = wmgr->recoveryWallet(WALLET_NAME, seed1);
ASSERT_TRUE(wallet2->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->seed() == seed1);
- ASSERT_TRUE(wallet2->address() == address1);
+ ASSERT_TRUE(wallet2->mainAddress() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet2));
}
@@ -387,7 +387,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet1)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
std::string seed1 = wallet1->seed();
- std::string address1 = wallet1->address();
+ std::string address1 = wallet1->mainAddress();
ASSERT_TRUE(wallet1->store(""));
ASSERT_TRUE(wallet1->store(WALLET_NAME_COPY));
@@ -395,7 +395,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet1)
Monero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME_COPY, WALLET_PASS);
ASSERT_TRUE(wallet2->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->seed() == seed1);
- ASSERT_TRUE(wallet2->address() == address1);
+ ASSERT_TRUE(wallet2->mainAddress() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet2));
}
@@ -404,7 +404,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet2)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
std::string seed1 = wallet1->seed();
- std::string address1 = wallet1->address();
+ std::string address1 = wallet1->mainAddress();
ASSERT_TRUE(wallet1->store(WALLET_NAME_WITH_DIR));
ASSERT_TRUE(wmgr->closeWallet(wallet1));
@@ -412,7 +412,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet2)
wallet1 = wmgr->openWallet(WALLET_NAME_WITH_DIR, WALLET_PASS);
ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet1->seed() == seed1);
- ASSERT_TRUE(wallet1->address() == address1);
+ ASSERT_TRUE(wallet1->mainAddress() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
}
@@ -421,7 +421,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet3)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
std::string seed1 = wallet1->seed();
- std::string address1 = wallet1->address();
+ std::string address1 = wallet1->mainAddress();
ASSERT_FALSE(wallet1->store(WALLET_NAME_WITH_DIR_NON_WRITABLE));
ASSERT_TRUE(wmgr->closeWallet(wallet1));
@@ -435,7 +435,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet3)
wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS);
ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet1->seed() == seed1);
- ASSERT_TRUE(wallet1->address() == address1);
+ ASSERT_TRUE(wallet1->mainAddress() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
}
@@ -445,7 +445,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet4)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
std::string seed1 = wallet1->seed();
- std::string address1 = wallet1->address();
+ std::string address1 = wallet1->mainAddress();
ASSERT_TRUE(wallet1->store(""));
ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok);
@@ -458,7 +458,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet4)
wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS);
ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet1->seed() == seed1);
- ASSERT_TRUE(wallet1->address() == address1);
+ ASSERT_TRUE(wallet1->mainAddress() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
}
@@ -496,18 +496,18 @@ TEST_F(WalletTest1, WalletGeneratesIntegratedAddress)
TEST_F(WalletTest1, WalletShowsBalance)
{
Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
- ASSERT_TRUE(wallet1->balance() > 0);
- ASSERT_TRUE(wallet1->unlockedBalance() > 0);
+ ASSERT_TRUE(wallet1->balance(0) > 0);
+ ASSERT_TRUE(wallet1->unlockedBalance(0) > 0);
- uint64_t balance1 = wallet1->balance();
- uint64_t unlockedBalance1 = wallet1->unlockedBalance();
+ uint64_t balance1 = wallet1->balance(0);
+ uint64_t unlockedBalance1 = wallet1->unlockedBalance(0);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Monero::Wallet * wallet2 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
- ASSERT_TRUE(balance1 == wallet2->balance());
- std::cout << "wallet balance: " << wallet2->balance() << std::endl;
- ASSERT_TRUE(unlockedBalance1 == wallet2->unlockedBalance());
- std::cout << "wallet unlocked balance: " << wallet2->unlockedBalance() << std::endl;
+ ASSERT_TRUE(balance1 == wallet2->balance(0));
+ std::cout << "wallet balance: " << wallet2->balance(0) << std::endl;
+ ASSERT_TRUE(unlockedBalance1 == wallet2->unlockedBalance(0));
+ std::cout << "wallet unlocked balance: " << wallet2->unlockedBalance(0) << std::endl;
ASSERT_TRUE(wmgr->closeWallet(wallet2));
}
@@ -569,7 +569,7 @@ TEST_F(WalletTest1, WalletTransaction)
// make sure testnet daemon is running
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet1->refresh());
- uint64_t balance = wallet1->balance();
+ uint64_t balance = wallet1->balance(0);
ASSERT_TRUE(wallet1->status() == Monero::PendingTransaction::Status_Ok);
std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
@@ -580,14 +580,16 @@ TEST_F(WalletTest1, WalletTransaction)
PAYMENT_ID_EMPTY,
AMOUNT_10XMR,
MIXIN_COUNT,
+ 0,
+ std::set<uint32_t>{},
Monero::PendingTransaction::Priority_Medium);
ASSERT_TRUE(transaction->status() == Monero::PendingTransaction::Status_Ok);
wallet1->refresh();
- ASSERT_TRUE(wallet1->balance() == balance);
+ ASSERT_TRUE(wallet1->balance(0) == balance);
ASSERT_TRUE(transaction->amount() == AMOUNT_10XMR);
ASSERT_TRUE(transaction->commit());
- ASSERT_FALSE(wallet1->balance() == balance);
+ ASSERT_FALSE(wallet1->balance(0) == balance);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
}
@@ -611,14 +613,15 @@ TEST_F(WalletTest1, WalletTransactionWithMixin)
// make sure testnet daemon is running
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet1->refresh());
- uint64_t balance = wallet1->balance();
+ uint64_t balance = wallet1->balance(0);
ASSERT_TRUE(wallet1->status() == Monero::PendingTransaction::Status_Ok);
std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
for (auto mixin : mixins) {
std::cerr << "Transaction mixin count: " << mixin << std::endl;
+
Monero::PendingTransaction * transaction = wallet1->createTransaction(
- recepient_address, payment_id, AMOUNT_5XMR, mixin);
+ recepient_address, payment_id, AMOUNT_5XMR, mixin, 0, std::set<uint32_t>{});
std::cerr << "Transaction status: " << transaction->status() << std::endl;
std::cerr << "Transaction fee: " << Monero::Wallet::displayAmount(transaction->fee()) << std::endl;
@@ -629,7 +632,7 @@ TEST_F(WalletTest1, WalletTransactionWithMixin)
wallet1->refresh();
- ASSERT_TRUE(wallet1->balance() == balance);
+ ASSERT_TRUE(wallet1->balance(0) == balance);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
}
@@ -643,7 +646,7 @@ TEST_F(WalletTest1, WalletTransactionWithPriority)
// make sure testnet daemon is running
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet1->refresh());
- uint64_t balance = wallet1->balance();
+ uint64_t balance = wallet1->balance(0);
ASSERT_TRUE(wallet1->status() == Monero::PendingTransaction::Status_Ok);
std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
@@ -658,8 +661,9 @@ TEST_F(WalletTest1, WalletTransactionWithPriority)
for (auto it = priorities.begin(); it != priorities.end(); ++it) {
std::cerr << "Transaction priority: " << *it << std::endl;
+
Monero::PendingTransaction * transaction = wallet1->createTransaction(
- recepient_address, payment_id, AMOUNT_5XMR, mixin, *it);
+ recepient_address, payment_id, AMOUNT_5XMR, mixin, 0, std::set<uint32_t>{}, *it);
std::cerr << "Transaction status: " << transaction->status() << std::endl;
std::cerr << "Transaction fee: " << Monero::Wallet::displayAmount(transaction->fee()) << std::endl;
std::cerr << "Transaction error: " << transaction->errorString() << std::endl;
@@ -669,7 +673,7 @@ TEST_F(WalletTest1, WalletTransactionWithPriority)
wallet1->disposeTransaction(transaction);
}
wallet1->refresh();
- ASSERT_TRUE(wallet1->balance() == balance);
+ ASSERT_TRUE(wallet1->balance(0) == balance);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
}
@@ -715,7 +719,7 @@ TEST_F(WalletTest1, WalletTransactionAndHistory)
Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
PAYMENT_ID_EMPTY,
- AMOUNT_10XMR * 5, 1);
+ AMOUNT_10XMR * 5, 1, 0, std::set<uint32_t>{});
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->commit());
@@ -757,7 +761,7 @@ TEST_F(WalletTest1, WalletTransactionWithPaymentId)
Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
payment_id,
- AMOUNT_1XMR, 1);
+ AMOUNT_1XMR, 1, 0, std::set<uint32_t>{});
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->commit());
@@ -816,7 +820,7 @@ struct MyWalletListener : public Monero::WalletListener
virtual void moneySpent(const string &txId, uint64_t amount)
{
- std::cerr << "wallet: " << wallet->address() << "**** just spent money ("
+ std::cerr << "wallet: " << wallet->mainAddress() << "**** just spent money ("
<< txId << ", " << wallet->displayAmount(amount) << ")" << std::endl;
total_tx += amount;
send_triggered = true;
@@ -825,7 +829,7 @@ struct MyWalletListener : public Monero::WalletListener
virtual void moneyReceived(const string &txId, uint64_t amount)
{
- std::cout << "wallet: " << wallet->address() << "**** just received money ("
+ std::cout << "wallet: " << wallet->mainAddress() << "**** just received money ("
<< txId << ", " << wallet->displayAmount(amount) << ")" << std::endl;
total_rx += amount;
receive_triggered = true;
@@ -834,7 +838,7 @@ struct MyWalletListener : public Monero::WalletListener
virtual void unconfirmedMoneyReceived(const string &txId, uint64_t amount)
{
- std::cout << "wallet: " << wallet->address() << "**** just received unconfirmed money ("
+ std::cout << "wallet: " << wallet->mainAddress() << "**** just received unconfirmed money ("
<< txId << ", " << wallet->displayAmount(amount) << ")" << std::endl;
// Don't trigger recieve until tx is mined
// total_rx += amount;
@@ -844,7 +848,7 @@ struct MyWalletListener : public Monero::WalletListener
virtual void newBlock(uint64_t height)
{
-// std::cout << "wallet: " << wallet->address()
+// std::cout << "wallet: " << wallet->mainAddress()
// <<", new block received, blockHeight: " << height << std::endl;
static int bc_height = wallet->daemonBlockChainHeight();
std::cout << height
@@ -920,17 +924,17 @@ TEST_F(WalletTest2, WalletCallbackSent)
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_src->refresh());
MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src);
- uint64_t balance = wallet_src->balance();
- std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance()) << std::endl;
+ uint64_t balance = wallet_src->balance(0);
+ std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl;
Monero::Wallet * wallet_dst = wmgr->openWallet(CURRENT_DST_WALLET, TESTNET_WALLET_PASS, true);
uint64_t amount = AMOUNT_1XMR * 5;
- std::cout << "** Sending " << Monero::Wallet::displayAmount(amount) << " to " << wallet_dst->address();
+ std::cout << "** Sending " << Monero::Wallet::displayAmount(amount) << " to " << wallet_dst->mainAddress();
- Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->address(),
+ Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->mainAddress(),
PAYMENT_ID_EMPTY,
- amount, 1);
+ amount, 1, 0, std::set<uint32_t>{});
std::cout << "** Committing transaction: " << Monero::Wallet::displayAmount(tx->amount())
<< " with fee: " << Monero::Wallet::displayAmount(tx->fee());
@@ -944,8 +948,8 @@ TEST_F(WalletTest2, WalletCallbackSent)
std::cerr << "TEST: send lock acquired...\n";
ASSERT_TRUE(wallet_src_listener->send_triggered);
ASSERT_TRUE(wallet_src_listener->update_triggered);
- std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance()) << std::endl;
- ASSERT_TRUE(wallet_src->balance() < balance);
+ std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl;
+ ASSERT_TRUE(wallet_src->balance(0) < balance);
wmgr->closeWallet(wallet_src);
wmgr->closeWallet(wallet_dst);
}
@@ -958,20 +962,20 @@ TEST_F(WalletTest2, WalletCallbackReceived)
// make sure testnet daemon is running
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_src->refresh());
- std::cout << "** Balance src1: " << wallet_src->displayAmount(wallet_src->balance()) << std::endl;
+ std::cout << "** Balance src1: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl;
Monero::Wallet * wallet_dst = wmgr->openWallet(CURRENT_DST_WALLET, TESTNET_WALLET_PASS, true);
ASSERT_TRUE(wallet_dst->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_dst->refresh());
- uint64_t balance = wallet_dst->balance();
- std::cout << "** Balance dst1: " << wallet_dst->displayAmount(wallet_dst->balance()) << std::endl;
+ uint64_t balance = wallet_dst->balance(0);
+ std::cout << "** Balance dst1: " << wallet_dst->displayAmount(wallet_dst->balance(0)) << std::endl;
std::unique_ptr<MyWalletListener> wallet_dst_listener (new MyWalletListener(wallet_dst));
uint64_t amount = AMOUNT_1XMR * 5;
- std::cout << "** Sending " << Monero::Wallet::displayAmount(amount) << " to " << wallet_dst->address();
- Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->address(),
+ std::cout << "** Sending " << Monero::Wallet::displayAmount(amount) << " to " << wallet_dst->mainAddress();
+ Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->mainAddress(),
PAYMENT_ID_EMPTY,
- amount, 1);
+ amount, 1, 0, std::set<uint32_t>{});
std::cout << "** Committing transaction: " << Monero::Wallet::displayAmount(tx->amount())
<< " with fee: " << Monero::Wallet::displayAmount(tx->fee());
@@ -987,10 +991,10 @@ TEST_F(WalletTest2, WalletCallbackReceived)
ASSERT_TRUE(wallet_dst_listener->receive_triggered);
ASSERT_TRUE(wallet_dst_listener->update_triggered);
- std::cout << "** Balance src2: " << wallet_dst->displayAmount(wallet_src->balance()) << std::endl;
- std::cout << "** Balance dst2: " << wallet_dst->displayAmount(wallet_dst->balance()) << std::endl;
+ std::cout << "** Balance src2: " << wallet_dst->displayAmount(wallet_src->balance(0)) << std::endl;
+ std::cout << "** Balance dst2: " << wallet_dst->displayAmount(wallet_dst->balance(0)) << std::endl;
- ASSERT_TRUE(wallet_dst->balance() > balance);
+ ASSERT_TRUE(wallet_dst->balance(0) > balance);
wmgr->closeWallet(wallet_src);
wmgr->closeWallet(wallet_dst);
@@ -1099,7 +1103,7 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync)
int SECONDS_TO_REFRESH = 120;
Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG);
std::string seed = wallet->seed();
- std::string address = wallet->address();
+ std::string address = wallet->mainAddress();
wmgr->closeWallet(wallet);
// deleting wallet files
@@ -1108,7 +1112,7 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync)
wallet = wmgr->recoveryWallet(WALLET_NAME_MAINNET, seed);
ASSERT_TRUE(wallet->status() == Monero::Wallet::Status_Ok);
- ASSERT_TRUE(wallet->address() == address);
+ ASSERT_TRUE(wallet->mainAddress() == address);
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH);
boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
diff --git a/tests/performance_tests/check_tx_signature.h b/tests/performance_tests/check_tx_signature.h
index 1e02bfcaa..02555fae8 100644
--- a/tests/performance_tests/check_tx_signature.h
+++ b/tests/performance_tests/check_tx_signature.h
@@ -62,10 +62,13 @@ public:
m_alice.generate();
std::vector<tx_destination_entry> destinations;
- destinations.push_back(tx_destination_entry(this->m_source_amount, m_alice.get_keys().m_account_address));
+ destinations.push_back(tx_destination_entry(this->m_source_amount, m_alice.get_keys().m_account_address, false));
crypto::secret_key tx_key;
- if (!construct_tx_and_get_tx_key(this->m_miners[this->real_source_idx].get_keys(), this->m_sources, destinations, std::vector<uint8_t>(), m_tx, 0, tx_key, rct))
+ std::vector<crypto::secret_key> additional_tx_keys;
+ std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
+ subaddresses[this->m_miners[this->real_source_idx].get_keys().m_account_address.m_spend_public_key] = {0,0};
+ if (!construct_tx_and_get_tx_key(this->m_miners[this->real_source_idx].get_keys(), subaddresses, this->m_sources, destinations, cryptonote::account_public_address{}, std::vector<uint8_t>(), m_tx, 0, tx_key, additional_tx_keys, rct))
return false;
get_transaction_prefix_hash(m_tx, m_tx_prefix_hash);
diff --git a/tests/performance_tests/construct_tx.h b/tests/performance_tests/construct_tx.h
index 90e4cf76e..e01ee5cfa 100644
--- a/tests/performance_tests/construct_tx.h
+++ b/tests/performance_tests/construct_tx.h
@@ -61,7 +61,7 @@ public:
for (size_t i = 0; i < out_count; ++i)
{
- m_destinations.push_back(tx_destination_entry(this->m_source_amount / out_count, m_alice.get_keys().m_account_address));
+ m_destinations.push_back(tx_destination_entry(this->m_source_amount / out_count, m_alice.get_keys().m_account_address, false));
}
return true;
@@ -70,7 +70,10 @@ public:
bool test()
{
crypto::secret_key tx_key;
- return cryptonote::construct_tx_and_get_tx_key(this->m_miners[this->real_source_idx].get_keys(), this->m_sources, m_destinations, std::vector<uint8_t>(), m_tx, 0, tx_key, rct);
+ std::vector<crypto::secret_key> additional_tx_keys;
+ std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
+ subaddresses[this->m_miners[this->real_source_idx].get_keys().m_account_address.m_spend_public_key] = {0,0};
+ return cryptonote::construct_tx_and_get_tx_key(this->m_miners[this->real_source_idx].get_keys(), subaddresses, this->m_sources, m_destinations, cryptonote::account_public_address{}, std::vector<uint8_t>(), m_tx, 0, tx_key, additional_tx_keys, rct);
}
private:
diff --git a/tests/performance_tests/ge_frombytes_vartime.h b/tests/performance_tests/ge_frombytes_vartime.h
index 491cea097..a5e64aeb2 100644
--- a/tests/performance_tests/ge_frombytes_vartime.h
+++ b/tests/performance_tests/ge_frombytes_vartime.h
@@ -52,7 +52,7 @@ public:
m_alice.generate();
std::vector<tx_destination_entry> destinations;
- destinations.push_back(tx_destination_entry(1, m_alice.get_keys().m_account_address));
+ destinations.push_back(tx_destination_entry(1, m_alice.get_keys().m_account_address, false));
return construct_tx(this->m_miners[this->real_source_idx].get_keys(), this->m_sources, destinations, std::vector<uint8_t>(), m_tx, 0);
}
diff --git a/tests/performance_tests/generate_key_image_helper.h b/tests/performance_tests/generate_key_image_helper.h
index 1332e7f62..bc92303eb 100644
--- a/tests/performance_tests/generate_key_image_helper.h
+++ b/tests/performance_tests/generate_key_image_helper.h
@@ -45,6 +45,9 @@ public:
{
cryptonote::keypair in_ephemeral;
crypto::key_image ki;
- return cryptonote::generate_key_image_helper(m_bob.get_keys(), m_tx_pub_key, 0, in_ephemeral, ki);
+ std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
+ subaddresses[m_bob.get_keys().m_account_address.m_spend_public_key] = {0,0};
+ crypto::public_key out_key = boost::get<cryptonote::txout_to_key>(m_tx.vout[0].target).key;
+ return cryptonote::generate_key_image_helper(m_bob.get_keys(), subaddresses, out_key, m_tx_pub_key, m_additional_tx_pub_keys, 0, in_ephemeral, ki);
}
};
diff --git a/tests/performance_tests/is_out_to_acc.h b/tests/performance_tests/is_out_to_acc.h
index ed8951659..12ef0f79f 100644
--- a/tests/performance_tests/is_out_to_acc.h
+++ b/tests/performance_tests/is_out_to_acc.h
@@ -44,7 +44,7 @@ public:
bool test()
{
const cryptonote::txout_to_key& tx_out = boost::get<cryptonote::txout_to_key>(m_tx.vout[0].target);
- return cryptonote::is_out_to_acc(m_bob.get_keys(), tx_out, m_tx_pub_key, 0);
+ return cryptonote::is_out_to_acc(m_bob.get_keys(), tx_out, m_tx_pub_key, m_additional_tx_pub_keys, 0);
}
};
diff --git a/tests/performance_tests/single_tx_test_base.h b/tests/performance_tests/single_tx_test_base.h
index 9e38d979b..f284b4198 100644
--- a/tests/performance_tests/single_tx_test_base.h
+++ b/tests/performance_tests/single_tx_test_base.h
@@ -47,6 +47,7 @@ public:
return false;
m_tx_pub_key = get_tx_pub_key_from_extra(m_tx);
+ m_additional_tx_pub_keys = get_additional_tx_pub_keys_from_extra(m_tx);
return true;
}
@@ -54,4 +55,5 @@ protected:
cryptonote::account_base m_bob;
cryptonote::transaction m_tx;
crypto::public_key m_tx_pub_key;
+ std::vector<crypto::public_key> m_additional_tx_pub_keys;
};
diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt
index 1dac92bed..d5f090700 100644
--- a/tests/unit_tests/CMakeLists.txt
+++ b/tests/unit_tests/CMakeLists.txt
@@ -53,6 +53,7 @@ set(unit_tests_sources
mul_div.cpp
parse_amount.cpp
serialization.cpp
+ sha256.cpp
slow_memmem.cpp
test_tx_utils.cpp
test_peerlist.cpp
diff --git a/tests/unit_tests/ban.cpp b/tests/unit_tests/ban.cpp
index d15716a42..242e5fe1c 100644
--- a/tests/unit_tests/ban.cpp
+++ b/tests/unit_tests/ban.cpp
@@ -78,6 +78,7 @@ public:
uint8_t get_hard_fork_version(uint64_t height) const { return 0; }
cryptonote::difficulty_type get_block_cumulative_difficulty(uint64_t height) const { return 0; }
bool fluffy_blocks_enabled() const { return false; }
+ uint64_t prevalidate_block_hashes(uint64_t height, const std::list<crypto::hash> &hashes) { return 0; }
};
typedef nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<test_core>> Server;
diff --git a/tests/unit_tests/base58.cpp b/tests/unit_tests/base58.cpp
index c9d6245cb..75a1930b5 100644
--- a/tests/unit_tests/base58.cpp
+++ b/tests/unit_tests/base58.cpp
@@ -474,43 +474,43 @@ TEST(get_account_address_as_str, works_correctly)
{
cryptonote::account_public_address addr;
ASSERT_TRUE(serialization::parse_binary(test_serialized_keys, addr));
- std::string addr_str = cryptonote::get_account_address_as_str(false, addr);
+ std::string addr_str = cryptonote::get_account_address_as_str(false, false, addr);
ASSERT_EQ(addr_str, test_keys_addr_str);
}
TEST(get_account_address_from_str, handles_valid_address)
{
- cryptonote::account_public_address addr;
- ASSERT_TRUE(cryptonote::get_account_address_from_str(addr, false, test_keys_addr_str));
+ cryptonote::address_parse_info info;
+ ASSERT_TRUE(cryptonote::get_account_address_from_str(info, false, test_keys_addr_str));
std::string blob;
- ASSERT_TRUE(serialization::dump_binary(addr, blob));
+ ASSERT_TRUE(serialization::dump_binary(info.address, blob));
ASSERT_EQ(blob, test_serialized_keys);
}
TEST(get_account_address_from_str, fails_on_invalid_address_format)
{
- cryptonote::account_public_address addr;
+ cryptonote::address_parse_info info;
std::string addr_str = test_keys_addr_str;
addr_str[0] = '0';
- ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, false, addr_str));
+ ASSERT_FALSE(cryptonote::get_account_address_from_str(info, false, addr_str));
}
TEST(get_account_address_from_str, fails_on_invalid_address_prefix)
{
std::string addr_str = base58::encode_addr(0, test_serialized_keys);
- cryptonote::account_public_address addr;
- ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, false, addr_str));
+ cryptonote::address_parse_info info;
+ ASSERT_FALSE(cryptonote::get_account_address_from_str(info, false, addr_str));
}
TEST(get_account_address_from_str, fails_on_invalid_address_content)
{
std::string addr_str = base58::encode_addr(config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX, test_serialized_keys.substr(1));
- cryptonote::account_public_address addr;
- ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, false, addr_str));
+ cryptonote::address_parse_info info;
+ ASSERT_FALSE(cryptonote::get_account_address_from_str(info, false, addr_str));
}
TEST(get_account_address_from_str, fails_on_invalid_address_spend_key)
@@ -519,8 +519,8 @@ TEST(get_account_address_from_str, fails_on_invalid_address_spend_key)
serialized_keys_copy[0] = '\0';
std::string addr_str = base58::encode_addr(config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX, serialized_keys_copy);
- cryptonote::account_public_address addr;
- ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, false, addr_str));
+ cryptonote::address_parse_info info;
+ ASSERT_FALSE(cryptonote::get_account_address_from_str(info, false, addr_str));
}
TEST(get_account_address_from_str, fails_on_invalid_address_view_key)
@@ -529,12 +529,12 @@ TEST(get_account_address_from_str, fails_on_invalid_address_view_key)
serialized_keys_copy.back() = '\x01';
std::string addr_str = base58::encode_addr(config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX, serialized_keys_copy);
- cryptonote::account_public_address addr;
- ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, false, addr_str));
+ cryptonote::address_parse_info info;
+ ASSERT_FALSE(cryptonote::get_account_address_from_str(info, false, addr_str));
}
TEST(get_account_address_from_str, parses_old_address_format)
{
- cryptonote::account_public_address addr;
- ASSERT_TRUE(cryptonote::get_account_address_from_str(addr, false, "002391bbbb24dea6fd95232e97594a27769d0153d053d2102b789c498f57a2b00b69cd6f2f5c529c1660f2f4a2b50178d6640c20ce71fe26373041af97c5b10236fc"));
+ cryptonote::address_parse_info info;
+ ASSERT_TRUE(cryptonote::get_account_address_from_str(info, false, "002391bbbb24dea6fd95232e97594a27769d0153d053d2102b789c498f57a2b00b69cd6f2f5c529c1660f2f4a2b50178d6640c20ce71fe26373041af97c5b10236fc"));
}
diff --git a/tests/unit_tests/dns_resolver.cpp b/tests/unit_tests/dns_resolver.cpp
index aca74a93f..8ac86146e 100644
--- a/tests/unit_tests/dns_resolver.cpp
+++ b/tests/unit_tests/dns_resolver.cpp
@@ -157,3 +157,17 @@ TEST(DNSResolver, GetTXTRecord)
addr = tools::DNSResolver::instance().get_dns_format_from_oa_address("donate.getmonero.org");
EXPECT_STREQ("donate.getmonero.org", addr.c_str());
}
+
+TEST(DNS_PUBLIC, empty) { EXPECT_STREQ("", tools::dns_utils::parse_dns_public("").c_str()); }
+TEST(DNS_PUBLIC, default) { EXPECT_STREQ("8.8.4.4", tools::dns_utils::parse_dns_public("tcp").c_str()); }
+TEST(DNS_PUBLIC, invalid_scheme) { EXPECT_STREQ("", tools::dns_utils::parse_dns_public("invalid").c_str()); }
+TEST(DNS_PUBLIC, invalid_ip_alpha) { EXPECT_STREQ("", tools::dns_utils::parse_dns_public("tcp://invalid").c_str()); }
+TEST(DNS_PUBLIC, invalid_ip_num1) { EXPECT_STREQ("", tools::dns_utils::parse_dns_public("tcp://3").c_str()); }
+TEST(DNS_PUBLIC, invalid_ip_num3) { EXPECT_STREQ("", tools::dns_utils::parse_dns_public("tcp://3.4.5").c_str()); }
+TEST(DNS_PUBLIC, invalid_ip_num4_extra) { EXPECT_STREQ("", tools::dns_utils::parse_dns_public("tcp://3.4.5.6x").c_str()); }
+TEST(DNS_PUBLIC, invalid_ip_num4_range) { EXPECT_STREQ("", tools::dns_utils::parse_dns_public("tcp://3.4.542.6").c_str()); }
+TEST(DNS_PUBLIC, invalid_ip_dot) { EXPECT_STREQ("", tools::dns_utils::parse_dns_public("tcp://3.4.5.6.").c_str()); }
+TEST(DNS_PUBLIC, invalid_ip_num5) { EXPECT_STREQ("", tools::dns_utils::parse_dns_public("tcp://3.4.5.6.7").c_str()); }
+TEST(DNS_PUBLIC, invalid_ip_4_missing) { EXPECT_STREQ("", tools::dns_utils::parse_dns_public("tcp://3.4..7").c_str()); }
+TEST(DNS_PUBLIC, valid_ip_lo) { EXPECT_STREQ("127.0.0.1", tools::dns_utils::parse_dns_public("tcp://127.0.0.1").c_str()); }
+TEST(DNS_PUBLIC, valid_ip) { EXPECT_STREQ("3.4.5.6", tools::dns_utils::parse_dns_public("tcp://3.4.5.6").c_str()); }
diff --git a/tests/unit_tests/hashchain.cpp b/tests/unit_tests/hashchain.cpp
index 0fa0f784a..e764f6afc 100644
--- a/tests/unit_tests/hashchain.cpp
+++ b/tests/unit_tests/hashchain.cpp
@@ -122,7 +122,7 @@ TEST(hashchain, trim)
ASSERT_EQ(hashchain.size(), 3);
ASSERT_EQ(hashchain[2], make_hash(3));
hashchain.trim(3);
- ASSERT_EQ(hashchain.offset(), 3);
+ ASSERT_EQ(hashchain.offset(), 2); // never gets it empty
ASSERT_EQ(hashchain.size(), 3);
ASSERT_FALSE(hashchain.empty());
ASSERT_EQ(hashchain.genesis(), make_hash(1));
diff --git a/tests/unit_tests/mnemonics.cpp b/tests/unit_tests/mnemonics.cpp
index 05894adf4..39ec394a1 100644
--- a/tests/unit_tests/mnemonics.cpp
+++ b/tests/unit_tests/mnemonics.cpp
@@ -45,6 +45,7 @@
#include "mnemonics/french.h"
#include "mnemonics/dutch.h"
#include "mnemonics/esperanto.h"
+#include "mnemonics/lojban.h"
#include "mnemonics/english_old.h"
#include "mnemonics/language_base.h"
#include "mnemonics/singleton.h"
@@ -167,7 +168,8 @@ TEST(mnemonics, all_languages)
Language::Singleton<Language::Russian>::instance(),
Language::Singleton<Language::French>::instance(),
Language::Singleton<Language::Dutch>::instance(),
- Language::Singleton<Language::Esperanto>::instance()
+ Language::Singleton<Language::Esperanto>::instance(),
+ Language::Singleton<Language::Lojban>::instance()
});
for (std::vector<Language::Base*>::iterator it = languages.begin(); it != languages.end(); it++)
diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp
index e701a53ce..202c8718f 100644
--- a/tests/unit_tests/serialization.cpp
+++ b/tests/unit_tests/serialization.cpp
@@ -987,15 +987,15 @@ TEST(Serialization, portability_unsigned_tx)
ASSERT_TRUE(epee::string_tools::pod_to_hex(tse.mask) == "789bafff169ef206aa21219342c69ca52ce1d78d776c10b21d14bdd960fc7703");
// tcd.change_dts
ASSERT_TRUE(tcd.change_dts.amount == 9631208773403);
- ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, tcd.change_dts.addr) == "9svHk1wHPo3ULf2AZykghzcye6sitaRE4MaDjPC6uanTHCynHjJHZaiAb922PojE1GexhhRt1LVf5DC43feyrRZMLXQr3mk");
+ ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, false, tcd.change_dts.addr) == "9svHk1wHPo3ULf2AZykghzcye6sitaRE4MaDjPC6uanTHCynHjJHZaiAb922PojE1GexhhRt1LVf5DC43feyrRZMLXQr3mk");
// tcd.splitted_dsts
ASSERT_TRUE(tcd.splitted_dsts.size() == 2);
auto& splitted_dst0 = tcd.splitted_dsts[0];
auto& splitted_dst1 = tcd.splitted_dsts[1];
ASSERT_TRUE(splitted_dst0.amount == 1400000000000);
ASSERT_TRUE(splitted_dst1.amount == 9631208773403);
- ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst0.addr) == "9xnhrMczQkPeoGi6dyu6BgKAYX4tZsDs6KHCkyTStDBKL4M4pM1gfCR3utmTAcSaKHGa1R5o266FbdnubErmij3oMdLyYgA");
- ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst1.addr) == "9svHk1wHPo3ULf2AZykghzcye6sitaRE4MaDjPC6uanTHCynHjJHZaiAb922PojE1GexhhRt1LVf5DC43feyrRZMLXQr3mk");
+ ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, false, splitted_dst0.addr) == "9xnhrMczQkPeoGi6dyu6BgKAYX4tZsDs6KHCkyTStDBKL4M4pM1gfCR3utmTAcSaKHGa1R5o266FbdnubErmij3oMdLyYgA");
+ ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, false, splitted_dst1.addr) == "9svHk1wHPo3ULf2AZykghzcye6sitaRE4MaDjPC6uanTHCynHjJHZaiAb922PojE1GexhhRt1LVf5DC43feyrRZMLXQr3mk");
// tcd.selected_transfers
ASSERT_TRUE(tcd.selected_transfers.size() == 1);
ASSERT_TRUE(tcd.selected_transfers.front() == 2);
@@ -1008,7 +1008,7 @@ TEST(Serialization, portability_unsigned_tx)
ASSERT_TRUE(tcd.dests.size() == 1);
auto& dest = tcd.dests[0];
ASSERT_TRUE(dest.amount == 1400000000000);
- ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, dest.addr) == "9xnhrMczQkPeoGi6dyu6BgKAYX4tZsDs6KHCkyTStDBKL4M4pM1gfCR3utmTAcSaKHGa1R5o266FbdnubErmij3oMdLyYgA");
+ ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, false, dest.addr) == "9xnhrMczQkPeoGi6dyu6BgKAYX4tZsDs6KHCkyTStDBKL4M4pM1gfCR3utmTAcSaKHGa1R5o266FbdnubErmij3oMdLyYgA");
// transfers
ASSERT_TRUE(exported_txs.transfers.size() == 3);
auto& td0 = exported_txs.transfers[0];
@@ -1101,7 +1101,7 @@ TEST(Serialization, portability_signed_tx)
ASSERT_FALSE(ptx.dust_added_to_fee);
// ptx.change.{amount, addr}
ASSERT_TRUE(ptx.change_dts.amount == 9631208773403);
- ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, ptx.change_dts.addr) == "9svHk1wHPo3ULf2AZykghzcye6sitaRE4MaDjPC6uanTHCynHjJHZaiAb922PojE1GexhhRt1LVf5DC43feyrRZMLXQr3mk");
+ ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, false, ptx.change_dts.addr) == "9svHk1wHPo3ULf2AZykghzcye6sitaRE4MaDjPC6uanTHCynHjJHZaiAb922PojE1GexhhRt1LVf5DC43feyrRZMLXQr3mk");
// ptx.selected_transfers
ASSERT_TRUE(ptx.selected_transfers.size() == 1);
ASSERT_TRUE(ptx.selected_transfers.front() == 2);
@@ -1111,7 +1111,7 @@ TEST(Serialization, portability_signed_tx)
// ptx.dests
ASSERT_TRUE(ptx.dests.size() == 1);
ASSERT_TRUE(ptx.dests[0].amount == 1400000000000);
- ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, ptx.dests[0].addr) == "9xnhrMczQkPeoGi6dyu6BgKAYX4tZsDs6KHCkyTStDBKL4M4pM1gfCR3utmTAcSaKHGa1R5o266FbdnubErmij3oMdLyYgA");
+ ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, false, ptx.dests[0].addr) == "9xnhrMczQkPeoGi6dyu6BgKAYX4tZsDs6KHCkyTStDBKL4M4pM1gfCR3utmTAcSaKHGa1R5o266FbdnubErmij3oMdLyYgA");
// ptx.construction_data
auto& tcd = ptx.construction_data;
ASSERT_TRUE(tcd.sources.size() == 1);
@@ -1142,15 +1142,15 @@ TEST(Serialization, portability_signed_tx)
ASSERT_TRUE(epee::string_tools::pod_to_hex(tse.mask) == "789bafff169ef206aa21219342c69ca52ce1d78d776c10b21d14bdd960fc7703");
// ptx.construction_data.change_dts
ASSERT_TRUE(tcd.change_dts.amount == 9631208773403);
- ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, tcd.change_dts.addr) == "9svHk1wHPo3ULf2AZykghzcye6sitaRE4MaDjPC6uanTHCynHjJHZaiAb922PojE1GexhhRt1LVf5DC43feyrRZMLXQr3mk");
+ ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, false, tcd.change_dts.addr) == "9svHk1wHPo3ULf2AZykghzcye6sitaRE4MaDjPC6uanTHCynHjJHZaiAb922PojE1GexhhRt1LVf5DC43feyrRZMLXQr3mk");
// ptx.construction_data.splitted_dsts
ASSERT_TRUE(tcd.splitted_dsts.size() == 2);
auto& splitted_dst0 = tcd.splitted_dsts[0];
auto& splitted_dst1 = tcd.splitted_dsts[1];
ASSERT_TRUE(splitted_dst0.amount == 1400000000000);
ASSERT_TRUE(splitted_dst1.amount == 9631208773403);
- ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst0.addr) == "9xnhrMczQkPeoGi6dyu6BgKAYX4tZsDs6KHCkyTStDBKL4M4pM1gfCR3utmTAcSaKHGa1R5o266FbdnubErmij3oMdLyYgA");
- ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst1.addr) == "9svHk1wHPo3ULf2AZykghzcye6sitaRE4MaDjPC6uanTHCynHjJHZaiAb922PojE1GexhhRt1LVf5DC43feyrRZMLXQr3mk");
+ ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, false, splitted_dst0.addr) == "9xnhrMczQkPeoGi6dyu6BgKAYX4tZsDs6KHCkyTStDBKL4M4pM1gfCR3utmTAcSaKHGa1R5o266FbdnubErmij3oMdLyYgA");
+ ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, false, splitted_dst1.addr) == "9svHk1wHPo3ULf2AZykghzcye6sitaRE4MaDjPC6uanTHCynHjJHZaiAb922PojE1GexhhRt1LVf5DC43feyrRZMLXQr3mk");
// ptx.construction_data.selected_transfers
ASSERT_TRUE(tcd.selected_transfers.size() == 1);
ASSERT_TRUE(tcd.selected_transfers.front() == 2);
@@ -1163,7 +1163,7 @@ TEST(Serialization, portability_signed_tx)
ASSERT_TRUE(tcd.dests.size() == 1);
auto& dest = tcd.dests[0];
ASSERT_TRUE(dest.amount == 1400000000000);
- ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, dest.addr) == "9xnhrMczQkPeoGi6dyu6BgKAYX4tZsDs6KHCkyTStDBKL4M4pM1gfCR3utmTAcSaKHGa1R5o266FbdnubErmij3oMdLyYgA");
+ ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, false, dest.addr) == "9xnhrMczQkPeoGi6dyu6BgKAYX4tZsDs6KHCkyTStDBKL4M4pM1gfCR3utmTAcSaKHGa1R5o266FbdnubErmij3oMdLyYgA");
// key_images
ASSERT_TRUE(exported_txs.key_images.size() == 3);
auto& ki0 = exported_txs.key_images[0];
diff --git a/tests/unit_tests/sha256.cpp b/tests/unit_tests/sha256.cpp
new file mode 100644
index 000000000..f4ad39466
--- /dev/null
+++ b/tests/unit_tests/sha256.cpp
@@ -0,0 +1,45 @@
+// Copyright (c) 2017, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "gtest/gtest.h"
+
+#include "string_tools.h"
+#include "common/util.h"
+
+static bool check(const std::string &data, const char *expected_hash_hex)
+{
+ crypto::hash hash, expected_hash;
+ if (!epee::string_tools::hex_to_pod(expected_hash_hex, expected_hash))
+ return false;
+ return tools::sha256sum((const uint8_t*)data.data(), data.size(), hash) && hash == expected_hash;
+}
+
+TEST(sha256, empty) { ASSERT_TRUE(check(std::string(), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")); }
+TEST(sha256, small) { ASSERT_TRUE(check("0123456789", "84d89877f0d4041efb6bf91a16f0248f2fd573e6af05c19f96bedb9f882f7882")); }
+TEST(sha256, large) { ASSERT_TRUE(check(std::string(65536*256, 0), "080acf35a507ac9849cfcba47dc2ad83e01b75663a516279c8b9d243b719643e")); }
+