aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/core_proxy/core_proxy.cpp3
-rw-r--r--tests/core_tests/CMakeLists.txt1
-rw-r--r--tests/core_tests/chaingen.cpp4
-rw-r--r--tests/core_tests/multisig.cpp4
-rw-r--r--tests/core_tests/rct.cpp5
-rw-r--r--tests/core_tests/tx_validation.cpp3
-rw-r--r--tests/crypto/CMakeLists.txt3
-rw-r--r--tests/crypto/crypto.cpp12
-rw-r--r--tests/fuzz/CMakeLists.txt5
-rw-r--r--tests/gtest/include/gtest/internal/gtest-filepath.h2
-rw-r--r--tests/gtest/src/gtest-filepath.cc2
-rw-r--r--tests/libwallet_api_tests/CMakeLists.txt2
-rw-r--r--tests/libwallet_api_tests/main.cpp2
-rw-r--r--tests/libwallet_api_tests/scripts/README.md2
-rw-r--r--tests/performance_tests/generate_key_image_helper.h3
-rw-r--r--tests/performance_tests/is_out_to_acc.h2
-rw-r--r--tests/performance_tests/rct_mlsag.h4
-rw-r--r--tests/unit_tests/ringct.cpp31
-rw-r--r--tests/unit_tests/serialization.cpp41
-rw-r--r--tests/unit_tests/unit_tests_utils.h7
20 files changed, 82 insertions, 56 deletions
diff --git a/tests/core_proxy/core_proxy.cpp b/tests/core_proxy/core_proxy.cpp
index 8c9340318..f0a1eb5ce 100644
--- a/tests/core_proxy/core_proxy.cpp
+++ b/tests/core_proxy/core_proxy.cpp
@@ -80,8 +80,7 @@ int main(int argc, char* argv[])
po::options_description desc("Allowed options");
- // tools::get_default_data_dir() can't be called during static initialization
- command_line::add_arg(desc, cryptonote::arg_data_dir, tools::get_default_data_dir());
+ command_line::add_arg(desc, cryptonote::arg_data_dir);
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<tests::proxy_core> >::init_options(desc);
po::variables_map vm;
diff --git a/tests/core_tests/CMakeLists.txt b/tests/core_tests/CMakeLists.txt
index 4d2452e84..c8ee7d9db 100644
--- a/tests/core_tests/CMakeLists.txt
+++ b/tests/core_tests/CMakeLists.txt
@@ -70,6 +70,7 @@ target_link_libraries(core_tests
p2p
version
epee
+ device
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
set_property(TARGET core_tests
diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp
index c1bcc7a47..5e1525e3e 100644
--- a/tests/core_tests/chaingen.cpp
+++ b/tests/core_tests/chaingen.cpp
@@ -43,7 +43,7 @@
#include "cryptonote_basic/miner.h"
#include "chaingen.h"
-
+#include "device/device.hpp"
using namespace std;
using namespace epee;
@@ -368,7 +368,7 @@ bool init_spent_output_indices(map_output_idx_t& outs, map_output_t& outs_mine,
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);
+ 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, hw::get_device(("default")));
// lookup for this key image in the events vector
BOOST_FOREACH(auto& tx_pair, mtx) {
diff --git a/tests/core_tests/multisig.cpp b/tests/core_tests/multisig.cpp
index c35800e6c..936a4b742 100644
--- a/tests/core_tests/multisig.cpp
+++ b/tests/core_tests/multisig.cpp
@@ -34,7 +34,7 @@
#include "common/apply_permutation.h"
#include "chaingen.h"
#include "multisig.h"
-
+#include "device/device.hpp"
using namespace epee;
using namespace crypto;
using namespace cryptonote;
@@ -367,7 +367,7 @@ bool gen_multisig_tx_validation_base::generate_with(std::vector<test_event_entry
for (size_t n = 0; n < tx.vout.size(); ++n)
{
CHECK_AND_ASSERT_MES(typeid(txout_to_key) == tx.vout[n].target.type(), false, "Unexpected tx out type");
- if (is_out_to_acc_precomp(subaddresses, boost::get<txout_to_key>(tx.vout[n].target).key, derivation, additional_derivations, n))
+ if (is_out_to_acc_precomp(subaddresses, boost::get<txout_to_key>(tx.vout[n].target).key, derivation, additional_derivations, n, hw::get_device(("default"))))
{
++n_outs;
CHECK_AND_ASSERT_MES(tx.vout[n].amount == 0, false, "Destination amount is not zero");
diff --git a/tests/core_tests/rct.cpp b/tests/core_tests/rct.cpp
index 62799d842..55401c4cb 100644
--- a/tests/core_tests/rct.cpp
+++ b/tests/core_tests/rct.cpp
@@ -31,6 +31,7 @@
#include "ringct/rctSigs.h"
#include "chaingen.h"
#include "rct.h"
+#include "device/device.hpp"
using namespace epee;
using namespace crypto;
@@ -133,9 +134,9 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev
crypto::secret_key amount_key;
crypto::derivation_to_scalar(derivation, o, amount_key);
if (rct_txes[n].rct_signatures.type == rct::RCTTypeSimple || rct_txes[n].rct_signatures.type == rct::RCTTypeSimpleBulletproof)
- rct::decodeRctSimple(rct_txes[n].rct_signatures, rct::sk2rct(amount_key), o, rct_tx_masks[o+n*4]);
+ rct::decodeRctSimple(rct_txes[n].rct_signatures, rct::sk2rct(amount_key), o, rct_tx_masks[o+n*4], hw::get_device("default"));
else
- rct::decodeRct(rct_txes[n].rct_signatures, rct::sk2rct(amount_key), o, rct_tx_masks[o+n*4]);
+ rct::decodeRct(rct_txes[n].rct_signatures, rct::sk2rct(amount_key), o, rct_tx_masks[o+n*4], hw::get_device("default"));
}
CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk_txes[n], blk_last, miner_account,
diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp
index 6707cc003..d6d5236aa 100644
--- a/tests/core_tests/tx_validation.cpp
+++ b/tests/core_tests/tx_validation.cpp
@@ -30,6 +30,7 @@
#include "chaingen.h"
#include "tx_validation.h"
+#include "device/device.hpp"
using namespace epee;
using namespace crypto;
@@ -62,7 +63,7 @@ namespace
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);
+ 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, hw::get_device(("default")));
// put key image into tx input
txin_to_key input_to_key;
diff --git a/tests/crypto/CMakeLists.txt b/tests/crypto/CMakeLists.txt
index df96c57cc..c89049d50 100644
--- a/tests/crypto/CMakeLists.txt
+++ b/tests/crypto/CMakeLists.txt
@@ -42,7 +42,10 @@ add_executable(cncrypto-tests
${crypto_headers})
target_link_libraries(cncrypto-tests
PRIVATE
+ wallet
+ cryptonote_core
common
+ device
${Boost_SYSTEM_LIBRARY}
${EXTRA_LIBRARIES})
set_property(TARGET cncrypto-tests
diff --git a/tests/crypto/crypto.cpp b/tests/crypto/crypto.cpp
index 6a1dd1b29..90212bd0b 100644
--- a/tests/crypto/crypto.cpp
+++ b/tests/crypto/crypto.cpp
@@ -33,7 +33,7 @@
#include "crypto-tests.h"
bool check_scalar(const crypto::ec_scalar &scalar) {
- return crypto::sc_check(crypto::operator &(scalar)) == 0;
+ return sc_check(crypto::operator &(scalar)) == 0;
}
void random_scalar(crypto::ec_scalar &res) {
@@ -45,13 +45,13 @@ void hash_to_scalar(const void *data, std::size_t length, crypto::ec_scalar &res
}
void hash_to_point(const crypto::hash &h, crypto::ec_point &res) {
- crypto::ge_p2 point;
- crypto::ge_fromfe_frombytes_vartime(&point, reinterpret_cast<const unsigned char *>(&h));
- crypto::ge_tobytes(crypto::operator &(res), &point);
+ ge_p2 point;
+ ge_fromfe_frombytes_vartime(&point, reinterpret_cast<const unsigned char *>(&h));
+ ge_tobytes(crypto::operator &(res), &point);
}
void hash_to_ec(const crypto::public_key &key, crypto::ec_point &res) {
- crypto::ge_p3 tmp;
+ ge_p3 tmp;
crypto::hash_to_ec(key, tmp);
- crypto::ge_p3_tobytes(crypto::operator &(res), &tmp);
+ ge_p3_tobytes(crypto::operator &(res), &tmp);
}
diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
index 6d34b13e2..dfbbaeca6 100644
--- a/tests/fuzz/CMakeLists.txt
+++ b/tests/fuzz/CMakeLists.txt
@@ -32,6 +32,7 @@ target_link_libraries(block_fuzz_tests
cryptonote_core
p2p
epee
+ device
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
set_property(TARGET block_fuzz_tests
@@ -44,6 +45,7 @@ target_link_libraries(transaction_fuzz_tests
cryptonote_core
p2p
epee
+ device
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
set_property(TARGET transaction_fuzz_tests
@@ -57,6 +59,7 @@ target_link_libraries(signature_fuzz_tests
cryptonote_core
p2p
epee
+ device
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
set_property(TARGET signature_fuzz_tests
@@ -70,6 +73,7 @@ target_link_libraries(cold-outputs_fuzz_tests
cryptonote_core
p2p
epee
+ device
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
set_property(TARGET cold-outputs_fuzz_tests
@@ -83,6 +87,7 @@ target_link_libraries(cold-transaction_fuzz_tests
cryptonote_core
p2p
epee
+ device
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
set_property(TARGET cold-transaction_fuzz_tests
diff --git a/tests/gtest/include/gtest/internal/gtest-filepath.h b/tests/gtest/include/gtest/internal/gtest-filepath.h
index 7a13b4b0d..184450686 100644
--- a/tests/gtest/include/gtest/internal/gtest-filepath.h
+++ b/tests/gtest/include/gtest/internal/gtest-filepath.h
@@ -192,7 +192,7 @@ class GTEST_API_ FilePath {
void Normalize();
- // Returns a pointer to the last occurence of a valid path separator in
+ // Returns a pointer to the last occurrence of a valid path separator in
// the FilePath. On Windows, for example, both '/' and '\' are valid path
// separators. Returns NULL if no path separator was found.
const char* FindLastPathSeparator() const;
diff --git a/tests/gtest/src/gtest-filepath.cc b/tests/gtest/src/gtest-filepath.cc
index 0292dc119..3bb275488 100644
--- a/tests/gtest/src/gtest-filepath.cc
+++ b/tests/gtest/src/gtest-filepath.cc
@@ -130,7 +130,7 @@ FilePath FilePath::RemoveExtension(const char* extension) const {
return *this;
}
-// Returns a pointer to the last occurence of a valid path separator in
+// Returns a pointer to the last occurrence of a valid path separator in
// the FilePath. On Windows, for example, both '/' and '\' are valid path
// separators. Returns NULL if no path separator was found.
const char* FilePath::FindLastPathSeparator() const {
diff --git a/tests/libwallet_api_tests/CMakeLists.txt b/tests/libwallet_api_tests/CMakeLists.txt
index ef066d340..ef1b666ed 100644
--- a/tests/libwallet_api_tests/CMakeLists.txt
+++ b/tests/libwallet_api_tests/CMakeLists.txt
@@ -38,6 +38,8 @@ add_executable(libwallet_api_tests
${libwallet_api_tests_headers})
target_link_libraries(libwallet_api_tests
+ PUBLIC
+ device
PRIVATE
wallet_api
wallet
diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp
index 96e327ef1..1e63a12f3 100644
--- a/tests/libwallet_api_tests/main.cpp
+++ b/tests/libwallet_api_tests/main.cpp
@@ -841,7 +841,7 @@ struct MyWalletListener : public Monero::WalletListener
{
std::cout << "wallet: " << wallet->mainAddress() << "**** just received unconfirmed money ("
<< txId << ", " << wallet->displayAmount(amount) << ")" << std::endl;
- // Don't trigger recieve until tx is mined
+ // Don't trigger receive until tx is mined
// total_rx += amount;
// receive_triggered = true;
// cv_receive.notify_one();
diff --git a/tests/libwallet_api_tests/scripts/README.md b/tests/libwallet_api_tests/scripts/README.md
index 2705cc04b..3818a27d8 100644
--- a/tests/libwallet_api_tests/scripts/README.md
+++ b/tests/libwallet_api_tests/scripts/README.md
@@ -3,7 +3,7 @@
## Environment for the tests
* Running monero node, linked to private/public testnet.
By default, tests expect daemon running at ```localhost:38081```,
- can we overriden with enviroment variable ```TESTNET_DAEMON_ADDRESS=<your_daemon_address>```
+ can we overriden with environment variable ```TESTNET_DAEMON_ADDRESS=<your_daemon_address>```
[Manual](https://github.com/moneroexamples/private-testnet) explaining how to run private testnet.
* Directory with pre-generated wallets
diff --git a/tests/performance_tests/generate_key_image_helper.h b/tests/performance_tests/generate_key_image_helper.h
index 869e595fd..ede48b6ca 100644
--- a/tests/performance_tests/generate_key_image_helper.h
+++ b/tests/performance_tests/generate_key_image_helper.h
@@ -35,6 +35,7 @@
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "single_tx_test_base.h"
+#include "device/device.hpp"
class test_generate_key_image_helper : public single_tx_test_base
{
@@ -48,6 +49,6 @@ public:
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);
+ 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, hw::get_device("default"));
}
};
diff --git a/tests/performance_tests/is_out_to_acc.h b/tests/performance_tests/is_out_to_acc.h
index 2aaf00b36..9f81995ac 100644
--- a/tests/performance_tests/is_out_to_acc.h
+++ b/tests/performance_tests/is_out_to_acc.h
@@ -66,7 +66,7 @@ public:
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
subaddresses[m_bob.get_keys().m_account_address.m_spend_public_key] = {0,0};
std::vector<crypto::key_derivation> additional_derivations;
- boost::optional<cryptonote::subaddress_receive_info> info = cryptonote::is_out_to_acc_precomp(subaddresses, tx_out.key, m_derivation, additional_derivations, 0);
+ boost::optional<cryptonote::subaddress_receive_info> info = cryptonote::is_out_to_acc_precomp(subaddresses, tx_out.key, m_derivation, additional_derivations, 0, hw::get_device("default"));
return (bool)info;
}
diff --git a/tests/performance_tests/rct_mlsag.h b/tests/performance_tests/rct_mlsag.h
index 70fb36aec..888f4b260 100644
--- a/tests/performance_tests/rct_mlsag.h
+++ b/tests/performance_tests/rct_mlsag.h
@@ -65,7 +65,7 @@ public:
{
sk[j] = xm[ind][j];
}
- IIccss = MLSAG_Gen(rct::identity(), P, sk, NULL, NULL, ind, rows);
+ IIccss = MLSAG_Gen(rct::identity(), P, sk, NULL, NULL, ind, rows, hw::get_device("default"));
return true;
}
@@ -75,7 +75,7 @@ public:
if (ver)
MLSAG_Ver(rct::identity(), P, IIccss, rows);
else
- MLSAG_Gen(rct::identity(), P, sk, NULL, NULL, ind, rows);
+ MLSAG_Gen(rct::identity(), P, sk, NULL, NULL, ind, rows, hw::get_device("default"));
return true;
}
diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp
index d90a14542..b7fcbbcab 100644
--- a/tests/unit_tests/ringct.cpp
+++ b/tests/unit_tests/ringct.cpp
@@ -37,6 +37,7 @@
#include "ringct/rctTypes.h"
#include "ringct/rctSigs.h"
#include "ringct/rctOps.h"
+#include "device/device.hpp"
using namespace std;
using namespace crypto;
@@ -111,7 +112,7 @@ TEST(ringct, MG_sigs)
sk[j] = xm[ind][j];
}
key message = identity();
- mgSig IIccss = MLSAG_Gen(message, P, sk, NULL, NULL, ind, R);
+ mgSig IIccss = MLSAG_Gen(message, P, sk, NULL, NULL, ind, R, hw::get_device("default"));
ASSERT_TRUE(MLSAG_Ver(message, P, IIccss, R));
//#MG sig: false one
@@ -131,8 +132,8 @@ TEST(ringct, MG_sigs)
}
sk[j] = xx[ind][j];
}
- sk[2] = skGen();//asume we don't know one of the private keys..
- IIccss = MLSAG_Gen(message, P, sk, NULL, NULL, ind, R);
+ sk[2] = skGen();//assume we don't know one of the private keys..
+ IIccss = MLSAG_Gen(message, P, sk, NULL, NULL, ind, R, hw::get_device("default"));
ASSERT_FALSE(MLSAG_Ver(message, P, IIccss, R));
}
@@ -171,13 +172,13 @@ TEST(ringct, range_proofs)
destinations.push_back(Pk);
//compute rct data with mixin 500
- rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3);
+ rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
//verify rct data
ASSERT_TRUE(verRct(s));
//decode received amount
- decodeRct(s, amount_keys[1], 1, mask);
+ decodeRct(s, amount_keys[1], 1, mask, hw::get_device("default"));
// Ring CT with failing MG sig part should not verify!
// Since sum of inputs != outputs
@@ -188,13 +189,13 @@ TEST(ringct, range_proofs)
//compute rct data with mixin 500
- s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3);
+ s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
//verify rct data
ASSERT_FALSE(verRct(s));
//decode received amount
- decodeRct(s, amount_keys[1], 1, mask);
+ decodeRct(s, amount_keys[1], 1, mask, hw::get_device("default"));
}
TEST(ringct, range_proofs_with_fee)
@@ -235,13 +236,13 @@ TEST(ringct, range_proofs_with_fee)
destinations.push_back(Pk);
//compute rct data with mixin 500
- rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3);
+ rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
//verify rct data
ASSERT_TRUE(verRct(s));
//decode received amount
- decodeRct(s, amount_keys[1], 1, mask);
+ decodeRct(s, amount_keys[1], 1, mask, hw::get_device("default"));
// Ring CT with failing MG sig part should not verify!
// Since sum of inputs != outputs
@@ -252,13 +253,13 @@ TEST(ringct, range_proofs_with_fee)
//compute rct data with mixin 500
- s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3);
+ s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
//verify rct data
ASSERT_FALSE(verRct(s));
//decode received amount
- decodeRct(s, amount_keys[1], 1, mask);
+ decodeRct(s, amount_keys[1], 1, mask, hw::get_device("default"));
}
TEST(ringct, simple)
@@ -310,13 +311,13 @@ TEST(ringct, simple)
//compute sig with mixin 2
xmr_amount txnfee = 1;
- rctSig s = genRctSimple(message, sc, pc, destinations,inamounts, outamounts, amount_keys, NULL, NULL, txnfee, 2);
+ rctSig s = genRctSimple(message, sc, pc, destinations,inamounts, outamounts, amount_keys, NULL, NULL, txnfee, 2, hw::get_device("default"));
//verify ring ct signature
ASSERT_TRUE(verRctSimple(s));
//decode received amount corresponding to output pubkey index 1
- decodeRctSimple(s, amount_keys[1], 1, mask);
+ decodeRctSimple(s, amount_keys[1], 1, mask, hw::get_device("default"));
}
static rct::rctSig make_sample_rct_sig(int n_inputs, const uint64_t input_amounts[], int n_outputs, const uint64_t output_amounts[], bool last_is_fee)
@@ -344,7 +345,7 @@ static rct::rctSig make_sample_rct_sig(int n_inputs, const uint64_t input_amount
}
}
- return genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3);;
+ return genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
}
static rct::rctSig make_sample_simple_rct_sig(int n_inputs, const uint64_t input_amounts[], int n_outputs, const uint64_t output_amounts[], uint64_t fee)
@@ -370,7 +371,7 @@ static rct::rctSig make_sample_simple_rct_sig(int n_inputs, const uint64_t input
destinations.push_back(Pk);
}
- return genRctSimple(rct::zero(), sc, pc, destinations, inamounts, outamounts, amount_keys, NULL, NULL, fee, 3);;
+ return genRctSimple(rct::zero(), sc, pc, destinations, inamounts, outamounts, amount_keys, NULL, NULL, fee, 3, hw::get_device("default"));
}
static bool range_proof_test(bool expected_valid,
diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp
index aa116da04..00bb9e49c 100644
--- a/tests/unit_tests/serialization.cpp
+++ b/tests/unit_tests/serialization.cpp
@@ -47,6 +47,7 @@
#include "wallet/wallet2.h"
#include "gtest/gtest.h"
#include "unit_tests_utils.h"
+#include "device/device.hpp"
using namespace std;
using namespace crypto;
@@ -590,7 +591,7 @@ TEST(Serialization, serializes_ringct_types)
rct::skpkGen(Sk, Pk);
destinations.push_back(Pk);
//compute rct data with mixin 500
- s0 = rct::genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3);
+ s0 = rct::genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, NULL, NULL, 3, hw::get_device("default"));
mg0 = s0.p.MGs[0];
ASSERT_TRUE(serialization::dump_binary(mg0, blob));
@@ -713,9 +714,9 @@ TEST(Serialization, portability_wallet)
epee::string_tools::hex_to_pod("c5680d3735b90871ca5e3d90cd82d6483eed1151b9ab75c2c8c3a7d89e00a5a8", ki[0]);
epee::string_tools::hex_to_pod("d54cbd435a8d636ad9b01b8d4f3eb13bd0cf1ce98eddf53ab1617f9b763e66c0", ki[1]);
epee::string_tools::hex_to_pod("6c3cd6af97c4070a7aef9b1344e7463e29c7cd245076fdb65da447a34da3ca76", ki[2]);
- ASSERT_TRUE(w.m_key_images.find(ki[0])->second == 0);
- ASSERT_TRUE(w.m_key_images.find(ki[1])->second == 1);
- ASSERT_TRUE(w.m_key_images.find(ki[2])->second == 2);
+ ASSERT_EQ_MAP(0, w.m_key_images, ki[0]);
+ ASSERT_EQ_MAP(1, w.m_key_images, ki[1]);
+ ASSERT_EQ_MAP(2, w.m_key_images, ki[2]);
}
// unconfirmed txs
ASSERT_TRUE(w.m_unconfirmed_txs.size() == 0);
@@ -743,15 +744,19 @@ TEST(Serialization, portability_wallet)
// tx keys
ASSERT_TRUE(w.m_tx_keys.size() == 2);
{
- auto tx_key0 = w.m_tx_keys.begin();
- auto tx_key1 = tx_key0;
- ++tx_key1;
- if (epee::string_tools::pod_to_hex(tx_key0->first) == "6e7013684d35820f66c6679197ded9329bfe0e495effa47e7b25258799858dba")
- swap(tx_key0, tx_key1);
- ASSERT_TRUE(epee::string_tools::pod_to_hex(tx_key0->first) == "b9aac8c020ab33859e0c0b6331f46a8780d349e7ac17b067116e2d87bf48daad");
- ASSERT_TRUE(epee::string_tools::pod_to_hex(tx_key1->first) == "6e7013684d35820f66c6679197ded9329bfe0e495effa47e7b25258799858dba");
- ASSERT_TRUE(epee::string_tools::pod_to_hex(tx_key0->second) == "bf3614c6de1d06c09add5d92a5265d8c76af706f7bc6ac830d6b0d109aa87701");
- ASSERT_TRUE(epee::string_tools::pod_to_hex(tx_key1->second) == "e556884246df5a787def6732c6ea38f1e092fa13e5ea98f732b99c07a6332003");
+ const std::vector<std::pair<std::string, std::string>> txid_txkey =
+ {
+ {"b9aac8c020ab33859e0c0b6331f46a8780d349e7ac17b067116e2d87bf48daad", "bf3614c6de1d06c09add5d92a5265d8c76af706f7bc6ac830d6b0d109aa87701"},
+ {"6e7013684d35820f66c6679197ded9329bfe0e495effa47e7b25258799858dba", "e556884246df5a787def6732c6ea38f1e092fa13e5ea98f732b99c07a6332003"},
+ };
+ for (size_t i = 0; i < txid_txkey.size(); ++i)
+ {
+ crypto::hash txid;
+ crypto::secret_key txkey;
+ epee::string_tools::hex_to_pod(txid_txkey[i].first, txid);
+ epee::string_tools::hex_to_pod(txid_txkey[i].second, txkey);
+ ASSERT_EQ_MAP(txkey, w.m_tx_keys, txid);
+ }
}
// confirmed txs
ASSERT_TRUE(w.m_confirmed_txs.size() == 1);
@@ -761,8 +766,8 @@ TEST(Serialization, portability_wallet)
crypto::hash h[2];
epee::string_tools::hex_to_pod("15024343b38e77a1a9860dfed29921fa17e833fec837191a6b04fa7cb9605b8e", h[0]);
epee::string_tools::hex_to_pod("6e7013684d35820f66c6679197ded9329bfe0e495effa47e7b25258799858dba", h[1]);
- ASSERT_TRUE(w.m_tx_notes.find(h[0])->second == "sample note");
- ASSERT_TRUE(w.m_tx_notes.find(h[1])->second == "sample note 2");
+ ASSERT_EQ_MAP("sample note", w.m_tx_notes, h[0]);
+ ASSERT_EQ_MAP("sample note 2", w.m_tx_notes, h[1]);
}
// unconfirmed payments
ASSERT_TRUE(w.m_unconfirmed_payments.size() == 0);
@@ -773,9 +778,9 @@ TEST(Serialization, portability_wallet)
epee::string_tools::hex_to_pod("33f75f264574cb3a9ea5b24220a5312e183d36dc321c9091dfbb720922a4f7b0", pubkey[0]);
epee::string_tools::hex_to_pod("5066ff2ce9861b1d131cf16eeaa01264933a49f28242b97b153e922ec7b4b3cb", pubkey[1]);
epee::string_tools::hex_to_pod("0d8467e16e73d16510452b78823e082e05ee3a63788d40de577cf31eb555f0c8", pubkey[2]);
- ASSERT_TRUE(w.m_pub_keys.find(pubkey[0])->second == 0);
- ASSERT_TRUE(w.m_pub_keys.find(pubkey[1])->second == 1);
- ASSERT_TRUE(w.m_pub_keys.find(pubkey[2])->second == 2);
+ ASSERT_EQ_MAP(0, w.m_pub_keys, pubkey[0]);
+ ASSERT_EQ_MAP(1, w.m_pub_keys, pubkey[1]);
+ ASSERT_EQ_MAP(2, w.m_pub_keys, pubkey[2]);
}
// address book
ASSERT_TRUE(w.m_address_book.size() == 1);
diff --git a/tests/unit_tests/unit_tests_utils.h b/tests/unit_tests/unit_tests_utils.h
index 49301f5a8..ecd97e3d5 100644
--- a/tests/unit_tests/unit_tests_utils.h
+++ b/tests/unit_tests/unit_tests_utils.h
@@ -65,3 +65,10 @@ namespace unit_test
std::atomic<size_t> m_counter;
};
}
+
+# define ASSERT_EQ_MAP(val, map, key) \
+ do { \
+ auto found = map.find(key); \
+ ASSERT_TRUE(found != map.end()); \
+ ASSERT_EQ(val, found->second); \
+ } while (false)