aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/core_proxy/core_proxy.h3
-rw-r--r--tests/core_tests/chaingen.h10
-rw-r--r--tests/core_tests/tx_validation.cpp12
-rw-r--r--tests/crypto/CMakeLists.txt10
-rw-r--r--tests/daemon_tests/CMakeLists.txt2
-rw-r--r--tests/functional_tests/CMakeLists.txt2
-rw-r--r--tests/hash/CMakeLists.txt2
-rw-r--r--tests/performance_tests/CMakeLists.txt2
-rw-r--r--tests/unit_tests/ban.cpp3
-rw-r--r--tests/unit_tests/hardfork.cpp9
-rw-r--r--tests/unit_tests/mnemonics.cpp4
11 files changed, 44 insertions, 15 deletions
diff --git a/tests/core_proxy/core_proxy.h b/tests/core_proxy/core_proxy.h
index 106c62f23..58645edb5 100644
--- a/tests/core_proxy/core_proxy.h
+++ b/tests/core_proxy/core_proxy.h
@@ -90,7 +90,8 @@ namespace tests
size_t get_block_sync_size() const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
virtual void on_transaction_relayed(const cryptonote::blobdata& tx) {}
bool get_testnet() const { return false; }
- bool get_pool_transaction(const crypto::hash& id, cryptonote::transaction& tx) const { return false; }
+ bool get_pool_transaction(const crypto::hash& id, cryptonote::blobdata& tx_blob) const { return false; }
+ bool pool_has_tx(const crypto::hash &txid) const { return false; }
bool get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata, cryptonote::block>>& blocks, std::list<cryptonote::blobdata>& txs) const { return false; }
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<cryptonote::transaction>& txs, std::list<crypto::hash>& missed_txs) const { return false; }
bool get_block_by_hash(const crypto::hash &h, cryptonote::block &blk, bool *orphan = NULL) const { return false; }
diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h
index eef10312d..add48eebe 100644
--- a/tests/core_tests/chaingen.h
+++ b/tests/core_tests/chaingen.h
@@ -472,6 +472,16 @@ inline bool do_replay_events(std::vector<test_event_entry>& events)
MERROR("Failed to init core");
return false;
}
+
+ // start with a clean pool
+ std::vector<crypto::hash> pool_txs;
+ if (!c.get_pool_transaction_hashes(pool_txs))
+ {
+ MERROR("Failed to flush txpool");
+ return false;
+ }
+ c.get_blockchain_storage().flush_txes_from_pool(std::list<crypto::hash>(pool_txs.begin(), pool_txs.end()));
+
t_test_class validator;
bool ret = replay_events_through_core<t_test_class>(c, events, validator);
c.deinit();
diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp
index 885b95c69..66460e876 100644
--- a/tests/core_tests/tx_validation.cpp
+++ b/tests/core_tests/tx_validation.cpp
@@ -163,6 +163,15 @@ namespace
throw std::runtime_error("invalid public key wasn't found");
return crypto::public_key();
}
+
+ crypto::key_image generate_invalid_key_image()
+ {
+ crypto::key_image key_image;
+ // a random key image plucked from the blockchain
+ if (!epee::string_tools::hex_to_pod("6b9f5d1be7c950dc6e4e258c6ef75509412ba9ecaaf90e6886140151d1365b5e", key_image))
+ throw std::runtime_error("invalid key image wasn't found");
+ return key_image;
+ }
}
//----------------------------------------------------------------------------------------------------------------------
@@ -541,8 +550,7 @@ bool gen_tx_key_image_is_invalid::generate(std::vector<test_event_entry>& events
builder.step2_fill_inputs(miner_account.get_keys(), sources);
txin_to_key& in_to_key = boost::get<txin_to_key>(builder.m_tx.vin.front());
- crypto::public_key pub = generate_invalid_pub_key();
- memcpy(&in_to_key.k_image, &pub, sizeof(crypto::ec_point));
+ in_to_key.k_image = generate_invalid_key_image();
builder.step3_fill_outputs(destinations);
builder.step4_calc_hash();
diff --git a/tests/crypto/CMakeLists.txt b/tests/crypto/CMakeLists.txt
index e1c632a00..573c62ad4 100644
--- a/tests/crypto/CMakeLists.txt
+++ b/tests/crypto/CMakeLists.txt
@@ -37,17 +37,17 @@ set(crypto_sources
set(crypto_headers
crypto-tests.h)
-add_executable(crypto-tests
+add_executable(cncrypto-tests
${crypto_sources}
${crypto_headers})
-target_link_libraries(crypto-tests
+target_link_libraries(cncrypto-tests
PRIVATE
${Boost_SYSTEM_LIBRARY}
${EXTRA_LIBRARIES})
-set_property(TARGET crypto-tests
+set_property(TARGET cncrypto-tests
PROPERTY
FOLDER "tests")
add_test(
- NAME crypto
- COMMAND crypto-tests "${CMAKE_CURRENT_SOURCE_DIR}/tests.txt")
+ NAME cncrypto
+ COMMAND cncrypto-tests "${CMAKE_CURRENT_SOURCE_DIR}/tests.txt")
diff --git a/tests/daemon_tests/CMakeLists.txt b/tests/daemon_tests/CMakeLists.txt
index c6dc69e9d..b554bfec8 100644
--- a/tests/daemon_tests/CMakeLists.txt
+++ b/tests/daemon_tests/CMakeLists.txt
@@ -39,7 +39,7 @@ target_link_libraries(transfers
useragent
rpc
cryptonote_core
- crypto
+ cncrypto
common
epee
${GTEST_LIBRARIES})
diff --git a/tests/functional_tests/CMakeLists.txt b/tests/functional_tests/CMakeLists.txt
index 166476904..498fe3c2c 100644
--- a/tests/functional_tests/CMakeLists.txt
+++ b/tests/functional_tests/CMakeLists.txt
@@ -43,7 +43,7 @@ target_link_libraries(functional_tests
cryptonote_core
wallet
common
- crypto
+ cncrypto
epee
${Boost_REGEX_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
diff --git a/tests/hash/CMakeLists.txt b/tests/hash/CMakeLists.txt
index 0f579cc6a..5cc95efbb 100644
--- a/tests/hash/CMakeLists.txt
+++ b/tests/hash/CMakeLists.txt
@@ -36,7 +36,7 @@ add_executable(hash-tests
${hash_headers})
target_link_libraries(hash-tests
PRIVATE
- crypto
+ cncrypto
${EXTRA_LIBRARIES})
set_property(TARGET hash-tests
PROPERTY
diff --git a/tests/performance_tests/CMakeLists.txt b/tests/performance_tests/CMakeLists.txt
index 7845515de..2b3a0d6f8 100644
--- a/tests/performance_tests/CMakeLists.txt
+++ b/tests/performance_tests/CMakeLists.txt
@@ -53,7 +53,7 @@ target_link_libraries(performance_tests
PRIVATE
cryptonote_core
common
- crypto
+ cncrypto
epee
${Boost_CHRONO_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
diff --git a/tests/unit_tests/ban.cpp b/tests/unit_tests/ban.cpp
index 595085d7d..9816adb94 100644
--- a/tests/unit_tests/ban.cpp
+++ b/tests/unit_tests/ban.cpp
@@ -65,7 +65,8 @@ public:
size_t get_block_sync_size() const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
virtual void on_transaction_relayed(const cryptonote::blobdata& tx) {}
bool get_testnet() const { return false; }
- bool get_pool_transaction(const crypto::hash& id, cryptonote::transaction& tx) const { return false; }
+ bool get_pool_transaction(const crypto::hash& id, cryptonote::blobdata& tx_blob) const { return false; }
+ bool pool_has_tx(const crypto::hash &txid) const { return false; }
bool get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata, cryptonote::block>>& blocks, std::list<cryptonote::blobdata>& txs) const { return false; }
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<cryptonote::transaction>& txs, std::list<crypto::hash>& missed_txs) const { return false; }
bool get_block_by_hash(const crypto::hash &h, cryptonote::block &blk, bool *orphan = NULL) const { return false; }
diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp
index 08c4276c8..e29919e8f 100644
--- a/tests/unit_tests/hardfork.cpp
+++ b/tests/unit_tests/hardfork.cpp
@@ -112,6 +112,15 @@ public:
virtual bool is_read_only() const { return false; }
virtual std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>> get_output_histogram(const std::vector<uint64_t> &amounts, bool unlocked, uint64_t recent_cutoff) const { return std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>>(); }
+ virtual void add_txpool_tx(const transaction &tx, const txpool_tx_meta_t& details) {}
+ virtual void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t& details) {}
+ virtual uint64_t get_txpool_tx_count() const { return 0; }
+ virtual bool txpool_has_tx(const crypto::hash &txid) const { return false; }
+ virtual void remove_txpool_tx(const crypto::hash& txid) {}
+ virtual txpool_tx_meta_t get_txpool_tx_meta(const crypto::hash& txid) const { return txpool_tx_meta_t(); }
+ virtual cryptonote::blobdata get_txpool_tx_blob(const crypto::hash& txid) const { return ""; }
+ virtual bool for_all_txpool_txes(std::function<bool(const crypto::hash&, const txpool_tx_meta_t&, const cryptonote::blobdata*)>, bool include_blob = false) const { return false; }
+
virtual void add_block( const block& blk
, const size_t& block_size
, const difficulty_type& cumulative_difficulty
diff --git a/tests/unit_tests/mnemonics.cpp b/tests/unit_tests/mnemonics.cpp
index 956c5e1b2..553dcfb86 100644
--- a/tests/unit_tests/mnemonics.cpp
+++ b/tests/unit_tests/mnemonics.cpp
@@ -192,9 +192,9 @@ TEST(mnemonics, language_detection_with_bad_checksum)
res = crypto::ElectrumWords::words_to_bytes(base_seed, key, language_name);
ASSERT_EQ(true, res);
- ASSERT_STREQ(language_name.c_str(), "Portuguese");
+ ASSERT_STREQ(language_name.c_str(), "Português");
res = crypto::ElectrumWords::words_to_bytes(base_seed + " " + real_checksum, key, language_name);
ASSERT_EQ(true, res);
- ASSERT_STREQ(language_name.c_str(), "Portuguese");
+ ASSERT_STREQ(language_name.c_str(), "Português");
}