diff options
author | stoffu <stoffu@protonmail.ch> | 2018-03-20 09:52:16 +0900 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2018-05-30 09:49:52 +0900 |
commit | a79fc219b75173d9257ecebb604d1ec24c9f1c2d (patch) | |
tree | 6ddae269b0ebf76546aeefba8f25a2e860fc65a5 /tests/unit_tests/hardfork.cpp | |
parent | Merge pull request #3251 (diff) | |
download | monero-a79fc219b75173d9257ecebb604d1ec24c9f1c2d.tar.xz |
hardfork: fix get_earliest_ideal_height_for_version() to support non-existent versions
Diffstat (limited to '')
-rw-r--r-- | tests/unit_tests/hardfork.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp index 7c27b9c5d..372cee513 100644 --- a/tests/unit_tests/hardfork.cpp +++ b/tests/unit_tests/hardfork.cpp @@ -554,3 +554,28 @@ TEST(get, higher) ASSERT_EQ(hf.get_ideal_version(7), 3); } +TEST(get, earliest_ideal_height) +{ + TestDB db; + HardFork hf(db, 1, 0, 1, 1, 4, 50); + + // v h t + ASSERT_TRUE(hf.add_fork(1, 0, 0)); + ASSERT_TRUE(hf.add_fork(2, 2, 1)); + ASSERT_TRUE(hf.add_fork(5, 5, 2)); + ASSERT_TRUE(hf.add_fork(6, 10, 3)); + ASSERT_TRUE(hf.add_fork(9, 15, 4)); + hf.init(); + + ASSERT_EQ(hf.get_earliest_ideal_height_for_version(1), 0); + ASSERT_EQ(hf.get_earliest_ideal_height_for_version(2), 2); + ASSERT_EQ(hf.get_earliest_ideal_height_for_version(3), 5); + ASSERT_EQ(hf.get_earliest_ideal_height_for_version(4), 5); + ASSERT_EQ(hf.get_earliest_ideal_height_for_version(5), 5); + ASSERT_EQ(hf.get_earliest_ideal_height_for_version(6), 10); + ASSERT_EQ(hf.get_earliest_ideal_height_for_version(7), 15); + ASSERT_EQ(hf.get_earliest_ideal_height_for_version(8), 15); + ASSERT_EQ(hf.get_earliest_ideal_height_for_version(9), 15); + ASSERT_EQ(hf.get_earliest_ideal_height_for_version(10), std::numeric_limits<uint64_t>::max()); +} + |