mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 16:27:39 +00:00
unit_tests/hardfork: add tests for check_for_height()
This commit is contained in:
parent
a79fc219b7
commit
7e30eadb32
1 changed files with 24 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue