aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt4
-rw-r--r--tests/block_weight/CMakeLists.txt2
-rw-r--r--tests/core_proxy/CMakeLists.txt2
-rw-r--r--tests/core_tests/CMakeLists.txt2
-rw-r--r--tests/crypto/CMakeLists.txt4
-rw-r--r--tests/daemon_tests/CMakeLists.txt2
-rw-r--r--tests/difficulty/CMakeLists.txt2
-rw-r--r--tests/functional_tests/CMakeLists.txt4
-rw-r--r--tests/fuzz/CMakeLists.txt26
-rw-r--r--tests/hash/CMakeLists.txt2
-rw-r--r--tests/libwallet_api_tests/CMakeLists.txt2
-rw-r--r--tests/net_load_tests/CMakeLists.txt4
-rw-r--r--tests/performance_tests/CMakeLists.txt2
-rw-r--r--tests/trezor/CMakeLists.txt2
-rw-r--r--tests/unit_tests/CMakeLists.txt4
-rw-r--r--tests/unit_tests/block_reward.cpp18
-rw-r--r--tests/unit_tests/levin.cpp109
17 files changed, 141 insertions, 50 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c601b93ed..224784a18 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -106,7 +106,7 @@ set(hash_targets_sources
set(hash_targets_headers)
-add_executable(hash-target-tests
+monero_add_minimal_executable(hash-target-tests
${hash_targets_sources}
${hash_targets_headers})
target_link_libraries(hash-target-tests
@@ -149,7 +149,7 @@ foreach(BENCH IN LISTS MONERO_WALLET_CRYPTO_BENCH)
endforeach ()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/benchmark.h.in" "${MONERO_GENERATED_HEADERS_DIR}/tests/benchmark.h")
-add_executable(monero-wallet-crypto-bench benchmark.cpp ${BENCH_OBJECTS})
+monero_add_minimal_executable(monero-wallet-crypto-bench benchmark.cpp ${BENCH_OBJECTS})
target_link_libraries(monero-wallet-crypto-bench cncrypto)
add_test(NAME wallet-crypto-bench COMMAND monero-wallet-crypto-bench)
diff --git a/tests/block_weight/CMakeLists.txt b/tests/block_weight/CMakeLists.txt
index a59c9c1fc..9bde90be4 100644
--- a/tests/block_weight/CMakeLists.txt
+++ b/tests/block_weight/CMakeLists.txt
@@ -31,7 +31,7 @@ set(block_weight_sources
set(block_weight_headers)
-add_executable(block_weight
+monero_add_minimal_executable(block_weight
${block_weight_sources}
${block_weight_headers})
target_link_libraries(block_weight
diff --git a/tests/core_proxy/CMakeLists.txt b/tests/core_proxy/CMakeLists.txt
index 7896389f2..63c511665 100644
--- a/tests/core_proxy/CMakeLists.txt
+++ b/tests/core_proxy/CMakeLists.txt
@@ -32,7 +32,7 @@ set(core_proxy_sources
set(core_proxy_headers
core_proxy.h)
-add_executable(core_proxy
+monero_add_minimal_executable(core_proxy
${core_proxy_sources}
${core_proxy_headers})
target_link_libraries(core_proxy
diff --git a/tests/core_tests/CMakeLists.txt b/tests/core_tests/CMakeLists.txt
index 654233d03..7455639ca 100644
--- a/tests/core_tests/CMakeLists.txt
+++ b/tests/core_tests/CMakeLists.txt
@@ -68,7 +68,7 @@ set(core_tests_headers
rct2.h
wallet_tools.h)
-add_executable(core_tests
+monero_add_minimal_executable(core_tests
${core_tests_sources}
${core_tests_headers})
target_link_libraries(core_tests
diff --git a/tests/crypto/CMakeLists.txt b/tests/crypto/CMakeLists.txt
index dcf5d8fb0..c8ea5a604 100644
--- a/tests/crypto/CMakeLists.txt
+++ b/tests/crypto/CMakeLists.txt
@@ -37,7 +37,7 @@ set(crypto_sources
set(crypto_headers
crypto-tests.h)
-add_executable(cncrypto-tests
+monero_add_minimal_executable(cncrypto-tests
${crypto_sources}
${crypto_headers})
target_link_libraries(cncrypto-tests
@@ -53,7 +53,7 @@ add_test(
NAME cncrypto
COMMAND cncrypto-tests "${CMAKE_CURRENT_SOURCE_DIR}/tests.txt")
-add_executable(cnv4-jit-tests cnv4-jit.c)
+monero_add_minimal_executable(cnv4-jit-tests cnv4-jit.c)
target_link_libraries(cnv4-jit-tests
PRIVATE
common
diff --git a/tests/daemon_tests/CMakeLists.txt b/tests/daemon_tests/CMakeLists.txt
index 7735b5ecb..a3fce119d 100644
--- a/tests/daemon_tests/CMakeLists.txt
+++ b/tests/daemon_tests/CMakeLists.txt
@@ -31,7 +31,7 @@ set(transfers_sources
set(transfers_headers)
-add_executable(transfers
+monero_add_minimal_executable(transfers
${transfers_sources}
${transfers_headers})
target_link_libraries(transfers
diff --git a/tests/difficulty/CMakeLists.txt b/tests/difficulty/CMakeLists.txt
index c5c3bfb02..231038440 100644
--- a/tests/difficulty/CMakeLists.txt
+++ b/tests/difficulty/CMakeLists.txt
@@ -31,7 +31,7 @@ set(difficulty_sources
set(difficulty_headers)
-add_executable(difficulty-tests
+monero_add_minimal_executable(difficulty-tests
${difficulty_sources}
${difficulty_headers})
target_link_libraries(difficulty-tests
diff --git a/tests/functional_tests/CMakeLists.txt b/tests/functional_tests/CMakeLists.txt
index 6972be55f..462fd4b77 100644
--- a/tests/functional_tests/CMakeLists.txt
+++ b/tests/functional_tests/CMakeLists.txt
@@ -35,7 +35,7 @@ set(functional_tests_headers
transactions_flow_test.h
transactions_generation_from_blockchain.h)
-add_executable(functional_tests
+monero_add_minimal_executable(functional_tests
${functional_tests_sources}
${functional_tests_headers})
target_link_libraries(functional_tests
@@ -53,7 +53,7 @@ target_link_libraries(functional_tests
set(make_test_signature_sources
make_test_signature.cc)
-add_executable(make_test_signature
+monero_add_minimal_executable(make_test_signature
${make_test_signature_sources})
target_link_libraries(make_test_signature
diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
index 48a49edab..a599f86f8 100644
--- a/tests/fuzz/CMakeLists.txt
+++ b/tests/fuzz/CMakeLists.txt
@@ -26,7 +26,7 @@
# 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.
-add_executable(block_fuzz_tests block.cpp fuzzer.cpp)
+monero_add_minimal_executable(block_fuzz_tests block.cpp fuzzer.cpp)
target_link_libraries(block_fuzz_tests
PRIVATE
cryptonote_core
@@ -40,7 +40,7 @@ set_property(TARGET block_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(transaction_fuzz_tests transaction.cpp fuzzer.cpp)
+monero_add_minimal_executable(transaction_fuzz_tests transaction.cpp fuzzer.cpp)
target_link_libraries(transaction_fuzz_tests
PRIVATE
cryptonote_core
@@ -54,7 +54,7 @@ set_property(TARGET transaction_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(signature_fuzz_tests signature.cpp fuzzer.cpp)
+monero_add_minimal_executable(signature_fuzz_tests signature.cpp fuzzer.cpp)
target_link_libraries(signature_fuzz_tests
PRIVATE
wallet
@@ -69,7 +69,7 @@ set_property(TARGET signature_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(cold-outputs_fuzz_tests cold-outputs.cpp fuzzer.cpp)
+monero_add_minimal_executable(cold-outputs_fuzz_tests cold-outputs.cpp fuzzer.cpp)
target_link_libraries(cold-outputs_fuzz_tests
PRIVATE
wallet
@@ -84,7 +84,7 @@ set_property(TARGET cold-outputs_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(cold-transaction_fuzz_tests cold-transaction.cpp fuzzer.cpp)
+monero_add_minimal_executable(cold-transaction_fuzz_tests cold-transaction.cpp fuzzer.cpp)
target_link_libraries(cold-transaction_fuzz_tests
PRIVATE
wallet
@@ -99,7 +99,7 @@ set_property(TARGET cold-transaction_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(load-from-binary_fuzz_tests load_from_binary.cpp fuzzer.cpp)
+monero_add_minimal_executable(load-from-binary_fuzz_tests load_from_binary.cpp fuzzer.cpp)
target_link_libraries(load-from-binary_fuzz_tests
PRIVATE
common
@@ -112,7 +112,7 @@ set_property(TARGET load-from-binary_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(load-from-json_fuzz_tests load_from_json.cpp fuzzer.cpp)
+monero_add_minimal_executable(load-from-json_fuzz_tests load_from_json.cpp fuzzer.cpp)
target_link_libraries(load-from-json_fuzz_tests
PRIVATE
common
@@ -125,7 +125,7 @@ set_property(TARGET load-from-json_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(base58_fuzz_tests base58.cpp fuzzer.cpp)
+monero_add_minimal_executable(base58_fuzz_tests base58.cpp fuzzer.cpp)
target_link_libraries(base58_fuzz_tests
PRIVATE
common
@@ -138,7 +138,7 @@ set_property(TARGET base58_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(parse-url_fuzz_tests parse_url.cpp fuzzer.cpp)
+monero_add_minimal_executable(parse-url_fuzz_tests parse_url.cpp fuzzer.cpp)
target_link_libraries(parse-url_fuzz_tests
PRIVATE
epee
@@ -152,7 +152,7 @@ set_property(TARGET parse-url_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(http-client_fuzz_tests http-client.cpp fuzzer.cpp)
+monero_add_minimal_executable(http-client_fuzz_tests http-client.cpp fuzzer.cpp)
target_link_libraries(http-client_fuzz_tests
PRIVATE
epee
@@ -168,7 +168,7 @@ set_property(TARGET http-client_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(levin_fuzz_tests levin.cpp fuzzer.cpp)
+monero_add_minimal_executable(levin_fuzz_tests levin.cpp fuzzer.cpp)
target_link_libraries(levin_fuzz_tests
PRIVATE
common
@@ -184,7 +184,7 @@ set_property(TARGET levin_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(bulletproof_fuzz_tests bulletproof.cpp fuzzer.cpp)
+monero_add_minimal_executable(bulletproof_fuzz_tests bulletproof.cpp fuzzer.cpp)
target_link_libraries(bulletproof_fuzz_tests
PRIVATE
common
@@ -200,7 +200,7 @@ set_property(TARGET bulletproof_fuzz_tests
PROPERTY
FOLDER "tests")
-add_executable(tx-extra_fuzz_tests tx-extra.cpp fuzzer.cpp)
+monero_add_minimal_executable(tx-extra_fuzz_tests tx-extra.cpp fuzzer.cpp)
target_link_libraries(tx-extra_fuzz_tests
PRIVATE
cryptonote_basic
diff --git a/tests/hash/CMakeLists.txt b/tests/hash/CMakeLists.txt
index 91dfdff1e..1d7d4cc5e 100644
--- a/tests/hash/CMakeLists.txt
+++ b/tests/hash/CMakeLists.txt
@@ -31,7 +31,7 @@ set(hash_sources
set(hash_headers)
-add_executable(hash-tests
+monero_add_minimal_executable(hash-tests
${hash_sources}
${hash_headers})
target_link_libraries(hash-tests
diff --git a/tests/libwallet_api_tests/CMakeLists.txt b/tests/libwallet_api_tests/CMakeLists.txt
index 8d03399fa..1c7a7cae4 100644
--- a/tests/libwallet_api_tests/CMakeLists.txt
+++ b/tests/libwallet_api_tests/CMakeLists.txt
@@ -33,7 +33,7 @@ set(libwallet_api_tests_sources
set(libwallet_api_tests_headers
)
-add_executable(libwallet_api_tests
+monero_add_minimal_executable(libwallet_api_tests
${libwallet_api_tests_sources}
${libwallet_api_tests_headers})
diff --git a/tests/net_load_tests/CMakeLists.txt b/tests/net_load_tests/CMakeLists.txt
index 9bcc2d6ab..c334df4ba 100644
--- a/tests/net_load_tests/CMakeLists.txt
+++ b/tests/net_load_tests/CMakeLists.txt
@@ -32,7 +32,7 @@ set(clt_sources
set(clt_headers
net_load_tests.h)
-add_executable(net_load_tests_clt
+monero_add_minimal_executable(net_load_tests_clt
${clt_sources}
${clt_headers})
target_link_libraries(net_load_tests_clt
@@ -54,7 +54,7 @@ set(srv_sources
set(srv_headers
net_load_tests.h)
-add_executable(net_load_tests_srv
+monero_add_minimal_executable(net_load_tests_srv
${srv_sources}
${srv_headers})
target_link_libraries(net_load_tests_srv
diff --git a/tests/performance_tests/CMakeLists.txt b/tests/performance_tests/CMakeLists.txt
index 1a9da116f..542d204e0 100644
--- a/tests/performance_tests/CMakeLists.txt
+++ b/tests/performance_tests/CMakeLists.txt
@@ -55,7 +55,7 @@ set(performance_tests_headers
performance_utils.h
single_tx_test_base.h)
-add_executable(performance_tests
+monero_add_minimal_executable(performance_tests
${performance_tests_sources}
${performance_tests_headers})
target_link_libraries(performance_tests
diff --git a/tests/trezor/CMakeLists.txt b/tests/trezor/CMakeLists.txt
index 15ed5668d..382d8e46f 100644
--- a/tests/trezor/CMakeLists.txt
+++ b/tests/trezor/CMakeLists.txt
@@ -40,7 +40,7 @@ set(trezor_tests_headers
../core_tests/chaingen.h
../core_tests/wallet_tools.h)
-add_executable(trezor_tests
+monero_add_minimal_executable(trezor_tests
${trezor_tests_sources}
${trezor_tests_headers})
diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt
index a5984b2c9..33ef93288 100644
--- a/tests/unit_tests/CMakeLists.txt
+++ b/tests/unit_tests/CMakeLists.txt
@@ -101,7 +101,7 @@ set(unit_tests_sources
set(unit_tests_headers
unit_tests_utils.h)
-add_executable(unit_tests
+monero_add_minimal_executable(unit_tests
${unit_tests_sources}
${unit_tests_headers})
target_link_libraries(unit_tests
@@ -144,6 +144,6 @@ add_test(
NAME unit_tests
COMMAND unit_tests --data-dir "${TEST_DATA_DIR}")
-add_executable(test_notifier test_notifier.cpp)
+monero_add_minimal_executable(test_notifier test_notifier.cpp)
target_link_libraries(test_notifier ${EXTRA_LIBRARIES})
set_property(TARGET test_notifier PROPERTY FOLDER "tests")
diff --git a/tests/unit_tests/block_reward.cpp b/tests/unit_tests/block_reward.cpp
index 5f3335981..2f0ea92f3 100644
--- a/tests/unit_tests/block_reward.cpp
+++ b/tests/unit_tests/block_reward.cpp
@@ -138,24 +138,6 @@ namespace
ASSERT_FALSE(m_block_not_too_big);
}
-#ifdef __x86_64__ // For 64-bit systems only, because block size is limited to size_t.
- TEST_F(block_reward_and_current_block_weight, fails_on_huge_median_size)
- {
-#if !defined(NDEBUG)
- size_t huge_size = std::numeric_limits<uint32_t>::max() + UINT64_C(2);
- ASSERT_DEATH(do_test(huge_size, huge_size + 1), "");
-#endif
- }
-
- TEST_F(block_reward_and_current_block_weight, fails_on_huge_block_weight)
- {
-#if !defined(NDEBUG)
- size_t huge_size = std::numeric_limits<uint32_t>::max() + UINT64_C(2);
- ASSERT_DEATH(do_test(huge_size - 2, huge_size), "");
-#endif
- }
-#endif // __x86_64__
-
//--------------------------------------------------------------------------------------------------------------------
class block_reward_and_last_block_weights : public ::testing::Test
{
diff --git a/tests/unit_tests/levin.cpp b/tests/unit_tests/levin.cpp
index e7f9e126f..22638942d 100644
--- a/tests/unit_tests/levin.cpp
+++ b/tests/unit_tests/levin.cpp
@@ -619,6 +619,61 @@ TEST_F(levin_notify, stem_without_padding)
}
}
+TEST_F(levin_notify, stem_no_outs_without_padding)
+{
+ cryptonote::levin::notify notifier = make_notifier(0, true, false);
+
+ for (unsigned count = 0; count < 10; ++count)
+ add_connection(true);
+
+ {
+ const auto status = notifier.get_status();
+ EXPECT_FALSE(status.has_noise);
+ EXPECT_FALSE(status.connections_filled);
+ }
+ notifier.new_out_connection();
+ io_service_.poll();
+
+ std::vector<cryptonote::blobdata> txs(2);
+ txs[0].resize(100, 'f');
+ txs[1].resize(200, 'e');
+
+ std::vector<cryptonote::blobdata> sorted_txs = txs;
+ std::sort(sorted_txs.begin(), sorted_txs.end());
+
+ ASSERT_EQ(10u, contexts_.size());
+
+ auto context = contexts_.begin();
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem));
+
+ io_service_.reset();
+ ASSERT_LT(0u, io_service_.poll());
+ EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::fluff));
+ if (events_.has_stem_txes())
+ EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::stem));
+
+
+ notifier.run_fluff();
+ ASSERT_LT(0u, io_service_.poll());
+
+ std::size_t send_count = 0;
+ EXPECT_EQ(0u, context->process_send_queue());
+ for (++context; context != contexts_.end(); ++context)
+ {
+ send_count += context->process_send_queue();
+ }
+
+ EXPECT_EQ(9u, send_count);
+ ASSERT_EQ(9u, receiver_.notified_size());
+ for (unsigned count = 0; count < 9u; ++count)
+ {
+ auto notification = receiver_.get_notification<cryptonote::NOTIFY_NEW_TRANSACTIONS>().second;
+ EXPECT_EQ(sorted_txs, notification.txs);
+ EXPECT_TRUE(notification._.empty());
+ EXPECT_TRUE(notification.dandelionpp_fluff);
+ }
+}
+
TEST_F(levin_notify, local_without_padding)
{
cryptonote::levin::notify notifier = make_notifier(0, true, false);
@@ -934,6 +989,60 @@ TEST_F(levin_notify, stem_with_padding)
}
}
+TEST_F(levin_notify, stem_no_outs_with_padding)
+{
+ cryptonote::levin::notify notifier = make_notifier(0, true, true);
+
+ for (unsigned count = 0; count < 10; ++count)
+ add_connection(true);
+
+ {
+ const auto status = notifier.get_status();
+ EXPECT_FALSE(status.has_noise);
+ EXPECT_FALSE(status.connections_filled);
+ }
+ notifier.new_out_connection();
+ io_service_.poll();
+
+ std::vector<cryptonote::blobdata> txs(2);
+ txs[0].resize(100, 'f');
+ txs[1].resize(200, 'e');
+
+ std::vector<cryptonote::blobdata> sorted_txs = txs;
+ std::sort(sorted_txs.begin(), sorted_txs.end());
+
+ ASSERT_EQ(10u, contexts_.size());
+
+ auto context = contexts_.begin();
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem));
+
+ io_service_.reset();
+ ASSERT_LT(0u, io_service_.poll());
+ EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::fluff));
+ if (events_.has_stem_txes())
+ EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::stem));
+
+ notifier.run_fluff();
+ ASSERT_LT(0u, io_service_.poll());
+
+ std::size_t send_count = 0;
+ EXPECT_EQ(0u, context->process_send_queue());
+ for (++context; context != contexts_.end(); ++context)
+ {
+ send_count += context->process_send_queue();
+ }
+
+ EXPECT_EQ(9u, send_count);
+ ASSERT_EQ(9u, receiver_.notified_size());
+ for (unsigned count = 0; count < 9u; ++count)
+ {
+ auto notification = receiver_.get_notification<cryptonote::NOTIFY_NEW_TRANSACTIONS>().second;
+ EXPECT_EQ(sorted_txs, notification.txs);
+ EXPECT_FALSE(notification._.empty());
+ EXPECT_TRUE(notification.dandelionpp_fluff);
+ }
+}
+
TEST_F(levin_notify, local_with_padding)
{
cryptonote::levin::notify notifier = make_notifier(0, true, true);