diff options
author | Riccardo Spagni <ric@spagni.net> | 2014-10-08 21:38:55 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2014-10-08 21:38:55 +0200 |
commit | 1795c381c0537119cc26ae55b523f71ba029da79 (patch) | |
tree | d645a3bd987f4f2fdaa8e3eb4e5c8c48a720ec07 /tests/unit_tests | |
parent | miniupnpc static define change (diff) | |
download | monero-1795c381c0537119cc26ae55b523f71ba029da79.tar.xz |
fixed unit tests
Diffstat (limited to 'tests/unit_tests')
-rw-r--r-- | tests/unit_tests/base58.cpp | 3 | ||||
-rw-r--r-- | tests/unit_tests/block_reward.cpp | 19 | ||||
-rw-r--r-- | tests/unit_tests/dns_resolver.cpp | 5 | ||||
-rw-r--r-- | tests/unit_tests/parse_amount.cpp | 43 | ||||
-rw-r--r-- | tests/unit_tests/test_format_utils.cpp | 8 |
5 files changed, 43 insertions, 35 deletions
diff --git a/tests/unit_tests/base58.cpp b/tests/unit_tests/base58.cpp index 28fb27f25..cdd8c4d68 100644 --- a/tests/unit_tests/base58.cpp +++ b/tests/unit_tests/base58.cpp @@ -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) diff --git a/tests/unit_tests/block_reward.cpp b/tests/unit_tests/block_reward.cpp index bf6cc8c84..7ae088d97 100644 --- a/tests/unit_tests/block_reward.cpp +++ b/tests/unit_tests/block_reward.cpp @@ -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); } //-------------------------------------------------------------------------------------------------------------------- diff --git a/tests/unit_tests/dns_resolver.cpp b/tests/unit_tests/dns_resolver.cpp index d4b0efe43..e944411f3 100644 --- a/tests/unit_tests/dns_resolver.cpp +++ b/tests/unit_tests/dns_resolver.cpp @@ -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) { diff --git a/tests/unit_tests/parse_amount.cpp b/tests/unit_tests/parse_amount.cpp index 80770212a..5e677a0b2 100644 --- a/tests/unit_tests/parse_amount.cpp +++ b/tests/unit_tests/parse_amount.cpp @@ -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( 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(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(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 diff --git a/tests/unit_tests/test_format_utils.cpp b/tests/unit_tests/test_format_utils.cpp index 857b5b09f..9fa09b4e9 100644 --- a/tests/unit_tests/test_format_utils.cpp +++ b/tests/unit_tests/test_format_utils.cpp @@ -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); |