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_proxy/core_proxy.h3
-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
-rwxr-xr-xtests/functional_tests/mining.py23
-rw-r--r--tests/fuzz/CMakeLists.txt26
-rw-r--r--tests/fuzz/signature.cpp2
-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.cpp190
-rw-r--r--tests/unit_tests/node_server.cpp3
21 files changed, 204 insertions, 99 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_proxy/core_proxy.h b/tests/core_proxy/core_proxy.h
index 4a41b5002..ecfcc18ae 100644
--- a/tests/core_proxy/core_proxy.h
+++ b/tests/core_proxy/core_proxy.h
@@ -66,9 +66,10 @@ namespace tests
public:
+ virtual bool is_synchronized() const final { return true; }
void on_synchronized(){}
void safesyncmode(const bool){}
- uint64_t get_current_blockchain_height(){return 1;}
+ virtual uint64_t get_current_blockchain_height() const final {return 1;}
void set_target_blockchain_height(uint64_t) {}
bool init(const boost::program_options::variables_map& vm);
bool deinit(){return true;}
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/functional_tests/mining.py b/tests/functional_tests/mining.py
index c60bf8396..1eb6b0ba7 100755
--- a/tests/functional_tests/mining.py
+++ b/tests/functional_tests/mining.py
@@ -95,20 +95,19 @@ class MiningTest():
assert res_status.block_reward >= 600000000000
# wait till we mined a few of them
+ target_height = prev_height + 5
+ height = prev_height
timeout = 60 # randomx is slow to init
- timeout_height = prev_height
- while True:
- time.sleep(1)
- res_info = daemon.get_info()
- height = res_info.height
- if height >= prev_height + 5:
- break
- if height > timeout_height:
- timeout = 5
- timeout_height = height
+ while height < target_height:
+ seen_height = height
+ for _ in range(timeout):
+ time.sleep(1)
+ height = daemon.get_info().height
+ if height > seen_height:
+ break
else:
- timeout -= 1
- assert timeout >= 0
+ assert False, 'Failed to mine successor to block %d (initial block = %d)' % (seen_height, prev_height)
+ timeout = 10
if via_daemon:
res = daemon.stop_mining()
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/fuzz/signature.cpp b/tests/fuzz/signature.cpp
index c587ff6cd..443057a57 100644
--- a/tests/fuzz/signature.cpp
+++ b/tests/fuzz/signature.cpp
@@ -59,6 +59,6 @@ BEGIN_INIT_SIMPLE_FUZZER()
END_INIT_SIMPLE_FUZZER()
BEGIN_SIMPLE_FUZZER()
- tools::wallet2::message_signature_result_t result = wallet->verify("test", address, s);
+ tools::wallet2::message_signature_result_t result = wallet->verify("test", address, std::string((const char*)buf, len));
std::cout << "Signature " << (result.valid ? "valid" : "invalid") << std::endl;
END_SIMPLE_FUZZER()
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 15563e764..22638942d 100644
--- a/tests/unit_tests/levin.cpp
+++ b/tests/unit_tests/levin.cpp
@@ -120,6 +120,16 @@ namespace
{
std::map<cryptonote::relay_method, std::vector<cryptonote::blobdata>> relayed_;
+ virtual bool is_synchronized() const final
+ {
+ return false;
+ }
+
+ virtual uint64_t get_current_blockchain_height() const final
+ {
+ return 0;
+ }
+
virtual void on_transactions_relayed(epee::span<const cryptonote::blobdata> txes, cryptonote::relay_method relay) override final
{
std::vector<cryptonote::blobdata>& cached = relayed_[relay];
@@ -324,7 +334,8 @@ namespace
epee::byte_slice noise = nullptr;
if (noise_size)
noise = epee::levin::make_noise_notify(noise_size);
- return cryptonote::levin::notify{io_service_, connections_, std::move(noise), is_public, pad_txs};
+ epee::net_utils::zone zone = is_public ? epee::net_utils::zone::public_ : epee::net_utils::zone::i2p;
+ return cryptonote::levin::notify{io_service_, connections_, std::move(noise), zone, pad_txs, events_};
}
boost::uuids::random_generator random_generator_;
@@ -483,11 +494,11 @@ TEST_F(levin_notify, defaulted)
EXPECT_FALSE(status.has_noise);
EXPECT_FALSE(status.connections_filled);
}
- EXPECT_TRUE(notifier.send_txs({}, random_generator_(), events_, cryptonote::relay_method::local));
+ EXPECT_TRUE(notifier.send_txs({}, random_generator_(), cryptonote::relay_method::local));
std::vector<cryptonote::blobdata> txs(2);
txs[0].resize(100, 'e');
- EXPECT_FALSE(notifier.send_txs(std::move(txs), random_generator_(), events_, cryptonote::relay_method::local));
+ EXPECT_FALSE(notifier.send_txs(std::move(txs), random_generator_(), cryptonote::relay_method::local));
}
TEST_F(levin_notify, fluff_without_padding)
@@ -512,7 +523,7 @@ TEST_F(levin_notify, fluff_without_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::fluff));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::fluff));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -564,7 +575,7 @@ TEST_F(levin_notify, stem_without_padding)
while (!has_stemmed || !has_fluffed)
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::stem));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -608,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);
@@ -636,7 +702,7 @@ TEST_F(levin_notify, local_without_padding)
while (!has_stemmed || !has_fluffed)
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::local));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::local));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -708,7 +774,7 @@ TEST_F(levin_notify, forward_without_padding)
while (!has_stemmed || !has_fluffed)
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::forward));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::forward));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -727,7 +793,9 @@ TEST_F(levin_notify, forward_without_padding)
{
const std::size_t sent = context->process_send_queue();
if (sent && is_stem)
+ {
EXPECT_EQ(1u, (context - contexts_.begin()) % 2);
+ }
send_count += sent;
}
@@ -772,7 +840,7 @@ TEST_F(levin_notify, block_without_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::block));
+ EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::block));
io_service_.reset();
ASSERT_EQ(0u, io_service_.poll());
@@ -801,7 +869,7 @@ TEST_F(levin_notify, none_without_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::none));
+ EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::none));
io_service_.reset();
ASSERT_EQ(0u, io_service_.poll());
@@ -830,7 +898,7 @@ TEST_F(levin_notify, fluff_with_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::fluff));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::fluff));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -879,7 +947,7 @@ TEST_F(levin_notify, stem_with_padding)
while (!has_stemmed || !has_fluffed)
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::stem));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -921,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);
@@ -946,7 +1068,7 @@ TEST_F(levin_notify, local_with_padding)
while (!has_stemmed || !has_fluffed)
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::local));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::local));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1013,7 +1135,7 @@ TEST_F(levin_notify, forward_with_padding)
while (!has_stemmed || !has_fluffed)
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::forward));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::forward));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1077,7 +1199,7 @@ TEST_F(levin_notify, block_with_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::block));
+ EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::block));
io_service_.reset();
ASSERT_EQ(0u, io_service_.poll());
@@ -1106,7 +1228,7 @@ TEST_F(levin_notify, none_with_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::none));
+ EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::none));
io_service_.reset();
ASSERT_EQ(0u, io_service_.poll());
@@ -1135,7 +1257,7 @@ TEST_F(levin_notify, private_fluff_without_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::fluff));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::fluff));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1186,7 +1308,7 @@ TEST_F(levin_notify, private_stem_without_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::stem));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1237,7 +1359,7 @@ TEST_F(levin_notify, private_local_without_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::local));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::local));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1288,7 +1410,7 @@ TEST_F(levin_notify, private_forward_without_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::forward));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::forward));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1339,7 +1461,7 @@ TEST_F(levin_notify, private_block_without_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::block));
+ EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::block));
io_service_.reset();
ASSERT_EQ(0u, io_service_.poll());
@@ -1369,7 +1491,7 @@ TEST_F(levin_notify, private_none_without_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::none));
+ EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::none));
io_service_.reset();
ASSERT_EQ(0u, io_service_.poll());
@@ -1398,7 +1520,7 @@ TEST_F(levin_notify, private_fluff_with_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::fluff));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::fluff));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1448,7 +1570,7 @@ TEST_F(levin_notify, private_stem_with_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::stem));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1498,7 +1620,7 @@ TEST_F(levin_notify, private_local_with_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::local));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::local));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1548,7 +1670,7 @@ TEST_F(levin_notify, private_forward_with_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::forward));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::forward));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1598,7 +1720,7 @@ TEST_F(levin_notify, private_block_with_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::block));
+ EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::block));
io_service_.reset();
ASSERT_EQ(0u, io_service_.poll());
@@ -1627,7 +1749,7 @@ TEST_F(levin_notify, private_none_with_padding)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::none));
+ EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::none));
io_service_.reset();
ASSERT_EQ(0u, io_service_.poll());
@@ -1659,7 +1781,7 @@ TEST_F(levin_notify, stem_mappings)
for (;;)
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::stem));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1721,7 +1843,7 @@ TEST_F(levin_notify, stem_mappings)
for (unsigned i = 0; i < contexts_.size() * 2; i += 2)
{
auto& incoming = contexts_[i % contexts_.size()];
- EXPECT_TRUE(notifier.send_txs(txs, incoming.get_id(), events_, cryptonote::relay_method::stem));
+ EXPECT_TRUE(notifier.send_txs(txs, incoming.get_id(), cryptonote::relay_method::stem));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1782,7 +1904,7 @@ TEST_F(levin_notify, fluff_multiple)
for (;;)
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), events_, cryptonote::relay_method::stem));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1841,7 +1963,7 @@ TEST_F(levin_notify, fluff_multiple)
for (unsigned i = 0; i < contexts_.size() * 2; i += 2)
{
auto& incoming = contexts_[i % contexts_.size()];
- EXPECT_TRUE(notifier.send_txs(txs, incoming.get_id(), events_, cryptonote::relay_method::stem));
+ EXPECT_TRUE(notifier.send_txs(txs, incoming.get_id(), cryptonote::relay_method::stem));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1905,7 +2027,7 @@ TEST_F(levin_notify, noise)
EXPECT_EQ(0u, receiver_.notified_size());
}
- EXPECT_TRUE(notifier.send_txs(txs, incoming_id, events_, cryptonote::relay_method::local));
+ EXPECT_TRUE(notifier.send_txs(txs, incoming_id, cryptonote::relay_method::local));
notifier.run_stems();
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1927,7 +2049,7 @@ TEST_F(levin_notify, noise)
}
txs[0].resize(3000, 'r');
- EXPECT_TRUE(notifier.send_txs(txs, incoming_id, events_, cryptonote::relay_method::fluff));
+ EXPECT_TRUE(notifier.send_txs(txs, incoming_id, cryptonote::relay_method::fluff));
notifier.run_stems();
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -1996,7 +2118,7 @@ TEST_F(levin_notify, noise_stem)
EXPECT_EQ(0u, receiver_.notified_size());
}
- EXPECT_TRUE(notifier.send_txs(txs, incoming_id, events_, cryptonote::relay_method::stem));
+ EXPECT_TRUE(notifier.send_txs(txs, incoming_id, cryptonote::relay_method::stem));
notifier.run_stems();
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
diff --git a/tests/unit_tests/node_server.cpp b/tests/unit_tests/node_server.cpp
index 588e91d02..0191e5aa4 100644
--- a/tests/unit_tests/node_server.cpp
+++ b/tests/unit_tests/node_server.cpp
@@ -47,9 +47,10 @@ namespace cryptonote {
class test_core : public cryptonote::i_core_events
{
public:
+ virtual bool is_synchronized() const final { return true; }
void on_synchronized(){}
void safesyncmode(const bool){}
- uint64_t get_current_blockchain_height() const {return 1;}
+ virtual uint64_t get_current_blockchain_height() const final {return 1;}
void set_target_blockchain_height(uint64_t) {}
bool init(const boost::program_options::variables_map& vm) {return true ;}
bool deinit(){return true;}