aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests/block_reward.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_tests/block_reward.cpp')
-rw-r--r--tests/unit_tests/block_reward.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/tests/unit_tests/block_reward.cpp b/tests/unit_tests/block_reward.cpp
index ca863ded9..a897e4140 100644
--- a/tests/unit_tests/block_reward.cpp
+++ b/tests/unit_tests/block_reward.cpp
@@ -40,14 +40,14 @@ namespace
class block_reward_and_already_generated_coins : public ::testing::Test
{
protected:
- static const size_t current_block_size = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 / 2;
+ static const size_t current_block_weight = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 / 2;
bool m_block_not_too_big;
uint64_t m_block_reward;
};
#define TEST_ALREADY_GENERATED_COINS(already_generated_coins, expected_reward) \
- m_block_not_too_big = get_block_reward(0, current_block_size, already_generated_coins, m_block_reward,1); \
+ m_block_not_too_big = get_block_reward(0, current_block_weight, already_generated_coins, m_block_reward,1); \
ASSERT_TRUE(m_block_not_too_big); \
ASSERT_EQ(m_block_reward, expected_reward);
@@ -74,7 +74,7 @@ namespace
}
//--------------------------------------------------------------------------------------------------------------------
- class block_reward_and_current_block_size : public ::testing::Test
+ class block_reward_and_current_block_weight : public ::testing::Test
{
protected:
virtual void SetUp()
@@ -84,9 +84,9 @@ namespace
ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1, m_standard_block_reward);
}
- void do_test(size_t median_block_size, size_t current_block_size)
+ void do_test(size_t median_block_weight, size_t current_block_weight)
{
- m_block_not_too_big = get_block_reward(median_block_size, current_block_size, already_generated_coins, m_block_reward, 1);
+ m_block_not_too_big = get_block_reward(median_block_weight, current_block_weight, already_generated_coins, m_block_reward, 1);
}
static const uint64_t already_generated_coins = 0;
@@ -96,28 +96,28 @@ namespace
uint64_t m_standard_block_reward;
};
- TEST_F(block_reward_and_current_block_size, handles_block_size_less_relevance_level)
+ TEST_F(block_reward_and_current_block_weight, handles_block_weight_less_relevance_level)
{
do_test(0, CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 - 1);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_EQ(m_block_reward, m_standard_block_reward);
}
- TEST_F(block_reward_and_current_block_size, handles_block_size_eq_relevance_level)
+ TEST_F(block_reward_and_current_block_weight, handles_block_weight_eq_relevance_level)
{
do_test(0, CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_EQ(m_block_reward, m_standard_block_reward);
}
- TEST_F(block_reward_and_current_block_size, handles_block_size_gt_relevance_level)
+ TEST_F(block_reward_and_current_block_weight, handles_block_weight_gt_relevance_level)
{
do_test(0, CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 + 1);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_LT(m_block_reward, m_standard_block_reward);
}
- TEST_F(block_reward_and_current_block_size, handles_block_size_less_2_relevance_level)
+ TEST_F(block_reward_and_current_block_weight, handles_block_weight_less_2_relevance_level)
{
do_test(0, 2 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 - 1);
ASSERT_TRUE(m_block_not_too_big);
@@ -125,21 +125,21 @@ namespace
ASSERT_LT(0, m_block_reward);
}
- TEST_F(block_reward_and_current_block_size, handles_block_size_eq_2_relevance_level)
+ TEST_F(block_reward_and_current_block_weight, handles_block_weight_eq_2_relevance_level)
{
do_test(0, 2 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_EQ(0, m_block_reward);
}
- TEST_F(block_reward_and_current_block_size, handles_block_size_gt_2_relevance_level)
+ TEST_F(block_reward_and_current_block_weight, handles_block_weight_gt_2_relevance_level)
{
do_test(0, 2 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 + 1);
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_size, fails_on_huge_median_size)
+ 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);
@@ -147,7 +147,7 @@ namespace
#endif
}
- TEST_F(block_reward_and_current_block_size, fails_on_huge_block_size)
+ 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);
@@ -157,94 +157,94 @@ namespace
#endif // __x86_64__
//--------------------------------------------------------------------------------------------------------------------
- class block_reward_and_last_block_sizes : public ::testing::Test
+ class block_reward_and_last_block_weights : public ::testing::Test
{
protected:
virtual void SetUp()
{
- m_last_block_sizes.push_back(3 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
- m_last_block_sizes.push_back(5 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
- m_last_block_sizes.push_back(7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
- m_last_block_sizes.push_back(11 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
- m_last_block_sizes.push_back(13 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
+ m_last_block_weights.push_back(3 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
+ m_last_block_weights.push_back(5 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
+ m_last_block_weights.push_back(7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
+ m_last_block_weights.push_back(11 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
+ m_last_block_weights.push_back(13 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1);
- m_last_block_sizes_median = 7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1;
+ m_last_block_weights_median = 7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1;
- m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), 0, already_generated_coins, m_standard_block_reward, 1);
+ m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_weights), 0, already_generated_coins, m_standard_block_reward, 1);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1, m_standard_block_reward);
}
- void do_test(size_t current_block_size)
+ void do_test(size_t current_block_weight)
{
- m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), current_block_size, already_generated_coins, m_block_reward, 1);
+ m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_weights), current_block_weight, already_generated_coins, m_block_reward, 1);
}
static const uint64_t already_generated_coins = 0;
- std::vector<size_t> m_last_block_sizes;
- uint64_t m_last_block_sizes_median;
+ std::vector<size_t> m_last_block_weights;
+ uint64_t m_last_block_weights_median;
bool m_block_not_too_big;
uint64_t m_block_reward;
uint64_t m_standard_block_reward;
};
- TEST_F(block_reward_and_last_block_sizes, handles_block_size_less_median)
+ TEST_F(block_reward_and_last_block_weights, handles_block_weight_less_median)
{
- do_test(m_last_block_sizes_median - 1);
+ do_test(m_last_block_weights_median - 1);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_EQ(m_block_reward, m_standard_block_reward);
}
- TEST_F(block_reward_and_last_block_sizes, handles_block_size_eq_median)
+ TEST_F(block_reward_and_last_block_weights, handles_block_weight_eq_median)
{
- do_test(m_last_block_sizes_median);
+ do_test(m_last_block_weights_median);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_EQ(m_block_reward, m_standard_block_reward);
}
- TEST_F(block_reward_and_last_block_sizes, handles_block_size_gt_median)
+ TEST_F(block_reward_and_last_block_weights, handles_block_weight_gt_median)
{
- do_test(m_last_block_sizes_median + 1);
+ do_test(m_last_block_weights_median + 1);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_LT(m_block_reward, m_standard_block_reward);
}
- TEST_F(block_reward_and_last_block_sizes, handles_block_size_less_2_medians)
+ TEST_F(block_reward_and_last_block_weights, handles_block_weight_less_2_medians)
{
- do_test(2 * m_last_block_sizes_median - 1);
+ do_test(2 * m_last_block_weights_median - 1);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_LT(m_block_reward, m_standard_block_reward);
ASSERT_LT(0, m_block_reward);
}
- TEST_F(block_reward_and_last_block_sizes, handles_block_size_eq_2_medians)
+ TEST_F(block_reward_and_last_block_weights, handles_block_weight_eq_2_medians)
{
- do_test(2 * m_last_block_sizes_median);
+ do_test(2 * m_last_block_weights_median);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_EQ(0, m_block_reward);
}
- TEST_F(block_reward_and_last_block_sizes, handles_block_size_gt_2_medians)
+ TEST_F(block_reward_and_last_block_weights, handles_block_weight_gt_2_medians)
{
- do_test(2 * m_last_block_sizes_median + 1);
+ do_test(2 * m_last_block_weights_median + 1);
ASSERT_FALSE(m_block_not_too_big);
}
- TEST_F(block_reward_and_last_block_sizes, calculates_correctly)
+ TEST_F(block_reward_and_last_block_weights, calculates_correctly)
{
- ASSERT_EQ(0, m_last_block_sizes_median % 8);
+ ASSERT_EQ(0, m_last_block_weights_median % 8);
- do_test(m_last_block_sizes_median * 9 / 8);
+ do_test(m_last_block_weights_median * 9 / 8);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_EQ(m_block_reward, m_standard_block_reward * 63 / 64);
// 3/2 = 12/8
- do_test(m_last_block_sizes_median * 3 / 2);
+ do_test(m_last_block_weights_median * 3 / 2);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_EQ(m_block_reward, m_standard_block_reward * 3 / 4);
- do_test(m_last_block_sizes_median * 15 / 8);
+ do_test(m_last_block_weights_median * 15 / 8);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_EQ(m_block_reward, m_standard_block_reward * 15 / 64);
}