aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests
diff options
context:
space:
mode:
authorstoffu <stoffu@protonmail.ch>2018-03-20 11:09:58 +0900
committerstoffu <stoffu@protonmail.ch>2018-05-30 09:49:57 +0900
commit98cf62cc45d6edd8d35f326ba0736728e624d5fd (patch)
tree97062951dc5155191b94e6bf4788caa4cb5b45f8 /tests/unit_tests
parentunit_tests/hardfork: add tests for check_for_height() (diff)
downloadmonero-98cf62cc45d6edd8d35f326ba0736728e624d5fd.tar.xz
hardfork: fix get_next_version()
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/hardfork.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp
index ba3e95e7d..d33daca4c 100644
--- a/tests/unit_tests/hardfork.cpp
+++ b/tests/unit_tests/hardfork.cpp
@@ -256,6 +256,35 @@ TEST(check_for_height, Success)
}
}
+TEST(get, next_version)
+{
+ TestDB db;
+ HardFork hf(db);
+
+ ASSERT_TRUE(hf.add_fork(1, 0, 0));
+ ASSERT_TRUE(hf.add_fork(2, 5, 1));
+ ASSERT_TRUE(hf.add_fork(4, 10, 2));
+ hf.init();
+
+ for (uint64_t h = 0; h <= 4; ++h) {
+ ASSERT_EQ(2, hf.get_next_version());
+ db.add_block(mkblock(hf, h, 1), 0, 0, 0, crypto::hash());
+ ASSERT_TRUE(hf.add(db.get_block_from_height(h), h));
+ }
+
+ for (uint64_t h = 5; h <= 9; ++h) {
+ ASSERT_EQ(4, hf.get_next_version());
+ db.add_block(mkblock(hf, h, 2), 0, 0, 0, crypto::hash());
+ ASSERT_TRUE(hf.add(db.get_block_from_height(h), h));
+ }
+
+ for (uint64_t h = 10; h <= 15; ++h) {
+ ASSERT_EQ(4, hf.get_next_version());
+ db.add_block(mkblock(hf, h, 4), 0, 0, 0, crypto::hash());
+ ASSERT_TRUE(hf.add(db.get_block_from_height(h), h));
+ }
+}
+
TEST(states, Success)
{
TestDB db;