mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-25 17:02:26 +00:00
fixed unit tests
This commit is contained in:
parent
bc537ac095
commit
1795c381c0
5 changed files with 42 additions and 34 deletions
|
@ -466,7 +466,8 @@ namespace
|
|||
"\x64\x18\x74\x51\x3a\x03\x57\x78\xa0\xc1\x77\x8d\x83\x32\x01\xe9"
|
||||
"\x22\x09\x39\x68\x9e\xdf\x1a\xbd\x5b\xc1\xd0\x31\xf7\x3e\xcd\x6c"
|
||||
"\x99\x3a\xdd\x66\xd6\x80\x88\x70\x45\x6a\xfe\xb8\xe7\xee\xb6\x8d");
|
||||
std::string test_keys_addr_str = "2AaF4qEmER6dNeM6dfiBFL7kqund3HYGvMBF3ttsNd9SfzgYB6L7ep1Yg1osYJzLdaKAYSLVh6e6jKnAuzj3bw1oGyd1x7Z";
|
||||
// DON'T ever use this as a destination for funds, as the keys are right above this comment...
|
||||
std::string test_keys_addr_str = "4AzKEX4gXdJdNeM6dfiBFL7kqund3HYGvMBF3ttsNd9SfzgYB6L7ep1Yg1osYJzLdaKAYSLVh6e6jKnAuzj3bw1oGy9kXCb";
|
||||
}
|
||||
|
||||
TEST(get_account_address_as_str, works_correctly)
|
||||
|
|
|
@ -53,23 +53,24 @@ namespace
|
|||
|
||||
TEST_F(block_reward_and_already_generated_coins, handles_first_values)
|
||||
{
|
||||
TEST_ALREADY_GENERATED_COINS(0, 70368744177663);
|
||||
TEST_ALREADY_GENERATED_COINS(m_block_reward, 70368475742208);
|
||||
TEST_ALREADY_GENERATED_COINS(UINT64_C(2756434948434199641), 59853779316998);
|
||||
// 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_F(block_reward_and_already_generated_coins, correctly_steps_from_2_to_1)
|
||||
{
|
||||
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((2 << 18) + 1), 2);
|
||||
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - (2 << 18) , 2);
|
||||
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((2 << 18) - 1), 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_F(block_reward_and_already_generated_coins, handles_max)
|
||||
{
|
||||
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((1 << 18) + 1), 1);
|
||||
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - (1 << 18) , 1);
|
||||
TEST_ALREADY_GENERATED_COINS(MONEY_SUPPLY - ((1 << 18) - 1), 0);
|
||||
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);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -68,7 +68,8 @@ TEST(DNSResolver, IPv4Failure)
|
|||
ASSERT_EQ(0, ips.size());
|
||||
}
|
||||
|
||||
TEST(DNSResolver, IPv6Success)
|
||||
// It would be great to include an IPv6 test and assume it'll pass, but not every ISP / resolver plays nicely with IPv6;)
|
||||
/*TEST(DNSResolver, IPv6Success)
|
||||
{
|
||||
tools::DNSResolver resolver;
|
||||
|
||||
|
@ -85,7 +86,7 @@ TEST(DNSResolver, IPv6Success)
|
|||
ASSERT_EQ(1, ips.size());
|
||||
|
||||
ASSERT_STREQ("2606:2800:220:6d:26bf:1447:1097:aa7", ips[0].c_str());
|
||||
}
|
||||
}*/
|
||||
|
||||
TEST(DNSResolver, IPv6Failure)
|
||||
{
|
||||
|
|
|
@ -105,22 +105,27 @@ TEST_pos(0, 00_00000000);
|
|||
TEST_pos(0, 00_000000000);
|
||||
TEST_pos(0, 00_00000000000000000000000000000000);
|
||||
|
||||
TEST_pos(1, 0_00000001);
|
||||
TEST_pos(1, 0_000000010);
|
||||
TEST_pos(1, 0_000000010000000000000000000000000);
|
||||
TEST_pos(9, 0_00000009);
|
||||
TEST_pos(9, 0_000000090);
|
||||
TEST_pos(9, 0_000000090000000000000000000000000);
|
||||
TEST_pos(1, 0_000000000001);
|
||||
TEST_pos(1, 0_0000000000010);
|
||||
TEST_pos(1, 0_0000000000010000000000000000000000000);
|
||||
TEST_pos(9, 0_000000000009);
|
||||
TEST_pos(9, 0_0000000000090);
|
||||
TEST_pos(9, 0_0000000000090000000000000000000000000);
|
||||
|
||||
TEST_pos( 100000000, 1);
|
||||
TEST_pos( 6553500000000, 65535);
|
||||
TEST_pos( 429496729500000000, 4294967295);
|
||||
TEST_pos(18446744073700000000, 184467440737_);
|
||||
TEST_pos(18446744073700000000, 184467440737_0);
|
||||
TEST_pos(18446744073700000000, 184467440737_00000000);
|
||||
TEST_pos(18446744073700000000, 184467440737_000000000);
|
||||
TEST_pos(18446744073700000000, 184467440737_0000000000000000000);
|
||||
TEST_pos(18446744073709551615, 184467440737_09551615);
|
||||
TEST_pos(1000000000000, 1);
|
||||
TEST_pos(10000000000000, 10);
|
||||
TEST_pos(100000000000000, 100);
|
||||
TEST_pos(1000000000000000, 1000);
|
||||
TEST_pos(6553500000000000, 6553_5);
|
||||
TEST_pos(429496729500000000, 429496_7295);
|
||||
TEST_pos(18446744073700000000, 18446744_0737);
|
||||
TEST_pos(18446744073700000000, 18446744_0737000);
|
||||
TEST_pos(18446744073700000000, 18446744_07370000);
|
||||
TEST_pos(18446744073700000000, 18446744_073700000);
|
||||
TEST_pos(18446744073700000000, 18446744_0737000000000000000);
|
||||
|
||||
/* Max supply */
|
||||
TEST_pos(18446744073709551615, 18446744_073709551615);
|
||||
|
||||
// Invalid numbers
|
||||
TEST_neg_n(~, empty_string);
|
||||
|
@ -130,9 +135,9 @@ TEST_neg_n(-1, minus_1);
|
|||
TEST_neg_n(+1, plus_1);
|
||||
TEST_neg_n(_, only_point);
|
||||
|
||||
// A lot of fraction digits
|
||||
TEST_neg(0_000000001);
|
||||
TEST_neg(0_000000009);
|
||||
// Don't go below 10^-12
|
||||
TEST_neg(0_0000000000001);
|
||||
TEST_neg(0_0000000000009);
|
||||
TEST_neg(184467440737_000000001);
|
||||
|
||||
// Overflow
|
||||
|
|
|
@ -165,11 +165,11 @@ TEST(validate_parse_amount_case, validate_parse_amount)
|
|||
uint64_t res = 0;
|
||||
bool r = cryptonote::parse_amount(res, "0.0001");
|
||||
ASSERT_TRUE(r);
|
||||
ASSERT_EQ(res, 10000);
|
||||
ASSERT_EQ(res, 100000000);
|
||||
|
||||
r = cryptonote::parse_amount(res, "100.0001");
|
||||
ASSERT_TRUE(r);
|
||||
ASSERT_EQ(res, 10000010000);
|
||||
ASSERT_EQ(res, 100000100000000);
|
||||
|
||||
r = cryptonote::parse_amount(res, "000.0000");
|
||||
ASSERT_TRUE(r);
|
||||
|
@ -182,11 +182,11 @@ TEST(validate_parse_amount_case, validate_parse_amount)
|
|||
|
||||
r = cryptonote::parse_amount(res, " 100.0001 ");
|
||||
ASSERT_TRUE(r);
|
||||
ASSERT_EQ(res, 10000010000);
|
||||
ASSERT_EQ(res, 100000100000000);
|
||||
|
||||
r = cryptonote::parse_amount(res, " 100.0000 ");
|
||||
ASSERT_TRUE(r);
|
||||
ASSERT_EQ(res, 10000000000);
|
||||
ASSERT_EQ(res, 100000000000000);
|
||||
|
||||
r = cryptonote::parse_amount(res, " 100. 0000 ");
|
||||
ASSERT_FALSE(r);
|
||||
|
|
Loading…
Reference in a new issue