aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/functional_tests/mining.py2
-rw-r--r--tests/unit_tests/block_reward.cpp18
-rw-r--r--tests/unit_tests/levin.cpp76
3 files changed, 43 insertions, 53 deletions
diff --git a/tests/functional_tests/mining.py b/tests/functional_tests/mining.py
index 34b4aceab..1eb6b0ba7 100755
--- a/tests/functional_tests/mining.py
+++ b/tests/functional_tests/mining.py
@@ -107,7 +107,7 @@ class MiningTest():
break
else:
assert False, 'Failed to mine successor to block %d (initial block = %d)' % (seen_height, prev_height)
- timeout = 5
+ timeout = 10
if via_daemon:
res = daemon.stop_mining()
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..9ff68d927 100644
--- a/tests/unit_tests/levin.cpp
+++ b/tests/unit_tests/levin.cpp
@@ -120,6 +120,11 @@ namespace
{
std::map<cryptonote::relay_method, std::vector<cryptonote::blobdata>> relayed_;
+ uint64_t get_target_blockchain_height() const override
+ {
+ 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 +329,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 +489,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 +518,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 +570,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());
@@ -636,7 +642,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 +714,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 +733,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 +780,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 +809,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 +838,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 +887,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());
@@ -946,7 +954,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 +1021,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 +1085,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 +1114,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 +1143,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 +1194,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 +1245,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 +1296,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 +1347,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 +1377,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 +1406,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 +1456,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 +1506,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 +1556,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 +1606,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 +1635,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 +1667,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 +1729,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 +1790,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 +1849,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 +1913,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 +1935,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 +2004,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());