aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-11-09 21:22:32 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-11-10 09:45:51 +0000
commit2f254ff5999f1b814a91c33f982cb2fc0844ec66 (patch)
treed18eed234c70ae166640d0de21a956ec74f6263e /tests/unit_tests
parenthardfork: allow per-fork voting thresholds (diff)
downloadmonero-2f254ff5999f1b814a91c33f982cb2fc0844ec66.tar.xz
hardfork: add a get_ideal_version(uint64_t) function
It returns the ideal version for a given height, which is based on the minimum height for a fork, disregarding votes
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/hardfork.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp
index e7387db1f..1f6ef5bf0 100644
--- a/tests/unit_tests/hardfork.cpp
+++ b/tests/unit_tests/hardfork.cpp
@@ -480,3 +480,25 @@ TEST(reorganize, changed)
ASSERT_EQ(hf.get_current_version(), 2); // we did not bump to 3 this time
ASSERT_EQ(hf.get_start_height(3), std::numeric_limits<uint64_t>::max()); // not yet
}
+
+TEST(get, higher)
+{
+ TestDB db;
+ HardFork hf(db, 1, 0, 1, 1, 4, 50);
+
+ // v h t
+ ASSERT_TRUE(hf.add(1, 0, 0));
+ ASSERT_TRUE(hf.add(2, 2, 1));
+ ASSERT_TRUE(hf.add(3, 5, 2));
+ hf.init();
+
+ ASSERT_EQ(hf.get_ideal_version(0), 1);
+ ASSERT_EQ(hf.get_ideal_version(1), 1);
+ ASSERT_EQ(hf.get_ideal_version(2), 2);
+ ASSERT_EQ(hf.get_ideal_version(3), 2);
+ ASSERT_EQ(hf.get_ideal_version(4), 2);
+ ASSERT_EQ(hf.get_ideal_version(5), 3);
+ ASSERT_EQ(hf.get_ideal_version(6), 3);
+ ASSERT_EQ(hf.get_ideal_version(7), 3);
+}
+