Merge pull request #353

16d71a3 Fix block_reward unit tests (Rostislav)
This commit is contained in:
Riccardo Spagni 2015-07-27 10:43:49 +02:00
commit 0c85f3fa19
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD

View file

@ -49,28 +49,28 @@ namespace
#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); \
ASSERT_TRUE(m_block_not_too_big); \
ASSERT_EQ(m_block_reward, UINT64_C(expected_reward));
ASSERT_EQ(m_block_reward, expected_reward);
TEST_F(block_reward_and_already_generated_coins, handles_first_values)
{
// 17592186044415 from neozaru, confirmed by fluffypony
TEST_ALREADY_GENERATED_COINS(0, 17592186044415);
TEST_ALREADY_GENERATED_COINS(m_block_reward, 17592169267200);
TEST_ALREADY_GENERATED_COINS(UINT64_C(2756434948434199641), 14963444829249);
TEST_ALREADY_GENERATED_COINS(0, UINT64_C(17592186044415));
TEST_ALREADY_GENERATED_COINS(m_block_reward, UINT64_C(17592169267200));
TEST_ALREADY_GENERATED_COINS(UINT64_C(2756434948434199641), UINT64_C(14963444829249));
}
TEST_F(block_reward_and_already_generated_coins, correctly_steps_from_2_to_1)
{
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((2 << 20) + 1), 2);
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - (2 << 20) , 2);
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((2 << 20) - 1), 1);
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((2 << 20) + 1), FINAL_SUBSIDY_PER_MINUTE);
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - (2 << 20) , FINAL_SUBSIDY_PER_MINUTE);
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((2 << 20) - 1), FINAL_SUBSIDY_PER_MINUTE);
}
TEST_F(block_reward_and_already_generated_coins, handles_max)
{
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((1 << 20) + 1), 1);
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - (1 << 20) , 1);
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((1 << 20) - 1), 0);
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((1 << 20) + 1), FINAL_SUBSIDY_PER_MINUTE);
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - (1 << 20) , FINAL_SUBSIDY_PER_MINUTE);
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((1 << 20) - 1), FINAL_SUBSIDY_PER_MINUTE);
}
//--------------------------------------------------------------------------------------------------------------------