diff options
author | stoffu <stoffu@protonmail.ch> | 2018-03-20 11:02:41 +0900 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2018-05-30 09:49:55 +0900 |
commit | 7e30eadb3298ed176b2ac209dae8824f947cb415 (patch) | |
tree | 6f2ff960782eeb8478b3e424cacdef9604648e24 | |
parent | hardfork: fix get_earliest_ideal_height_for_version() to support non-existent... (diff) | |
download | monero-7e30eadb3298ed176b2ac209dae8824f947cb415.tar.xz |
unit_tests/hardfork: add tests for check_for_height()
-rw-r--r-- | tests/unit_tests/hardfork.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp index 372cee513..ba3e95e7d 100644 --- a/tests/unit_tests/hardfork.cpp +++ b/tests/unit_tests/hardfork.cpp @@ -232,6 +232,30 @@ TEST(ordering, Success) ASSERT_FALSE(hf.add_fork(5, 5, 4)); } +TEST(check_for_height, Success) +{ + TestDB db; + HardFork hf(db, 1, 0, 0, 0, 1, 0); // no voting + + ASSERT_TRUE(hf.add_fork(1, 0, 0)); + ASSERT_TRUE(hf.add_fork(2, 5, 1)); + hf.init(); + + for (uint64_t h = 0; h <= 4; ++h) { + ASSERT_TRUE(hf.check_for_height(mkblock(1, 1), h)); + ASSERT_FALSE(hf.check_for_height(mkblock(2, 2), h)); // block version is too high + 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 <= 10; ++h) { + ASSERT_FALSE(hf.check_for_height(mkblock(1, 1), h)); // block version is too low + ASSERT_TRUE(hf.check_for_height(mkblock(2, 2), h)); + db.add_block(mkblock(hf, h, 2), 0, 0, 0, crypto::hash()); + ASSERT_TRUE(hf.add(db.get_block_from_height(h), h)); + } +} + TEST(states, Success) { TestDB db; |