111 db.add_block(mkblock(1, 1), 0, 0, 0, 0, 0,
crypto::hash());
117 db.add_block(mkblock(1, 1), 0, 0, 0, 0, 0,
crypto::hash());
124 db.add_block(mkblock(2, 1), 0, 0, 0, 0, 0,
crypto::hash());
172 db.add_block(mkblock(hf, h, 1), 0, 0, 0, 0, 0,
crypto::hash());
176 for (
uint64_t h = 5; h <= 10; ++h) {
179 db.add_block(mkblock(hf, h, 2), 0, 0, 0, 0, 0,
crypto::hash());
196 db.add_block(mkblock(hf, h, 1), 0, 0, 0, 0, 0,
crypto::hash());
202 db.add_block(mkblock(hf, h, 2), 0, 0, 0, 0, 0,
crypto::hash());
206 for (
uint64_t h = 10; h <= 15; ++h) {
208 db.add_block(mkblock(hf, h, 4), 0, 0, 0, 0, 0,
crypto::hash());
287 for (
int history = 1; history <= 12; ++history) {
289 HardFork hf(db, 1, 0, 1, 1, history, 100);
299 static const uint8_t block_versions[] = { 1, 1, 4, 4, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 };
301 db.add_block(mkblock(hf, h, block_versions[h]), 0, 0, 0, 0, 0,
crypto::hash());
305 for (
uint64_t rh = 0; rh < 20; ++rh) {
307 for (
int hh = 0; hh < 20; ++hh) {
308 uint8_t version = hh >= history ? block_versions[hh - history] : 1;
318 HardFork hf(db, 1, 0, 1, 1, 4, 100);
329 static const uint8_t block_versions[] = { 1, 1, 4, 4, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 };
330 static const uint8_t expected_versions[] = { 1, 1, 1, 1, 1, 1, 4, 4, 7, 7, 9, 9, 9, 9, 9, 9 };
332 db.add_block(mkblock(hf, h, block_versions[h]), 0, 0, 0, 0, 0,
crypto::hash());
336 for (
uint64_t rh = 0; rh < 16; ++rh) {
338 for (
int hh = 0; hh < 16; ++hh) {
344 static const uint8_t block_versions_new[] = { 1, 1, 4, 4, 7, 7, 4, 7, 7, 7, 9, 9, 9, 9, 9, 1 };
345 static const uint8_t expected_versions_new[] = { 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 7, 7, 7, 9, 9 };
352 db.add_block(mkblock(hf, h, block_versions_new[h]), 0, 0, 0, 0, 0,
crypto::hash());
353 bool ret = hf.
add(db.get_block_from_height(h), h);
358 for (
int hh = 0; hh < 15; ++hh) {
392TEST(voting, different_thresholds)
406 static const uint8_t block_versions[] = { 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 };
407 static const uint8_t expected_versions[] = { 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4 };
409 for (
uint64_t h = 0; h <
sizeof(block_versions) /
sizeof(block_versions[0]); ++h) {
410 db.add_block(mkblock(hf, h, block_versions[h]), 0, 0, 0, 0, 0,
crypto::hash());
411 bool ret = hf.
add(db.get_block_from_height(h), h);
414 for (
uint64_t h = 0; h <
sizeof(expected_versions) /
sizeof(expected_versions[0]); ++h) {
435 static const uint8_t block_versions[] = { 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 };
436 static const uint8_t expected_versions[] = { 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4 };
437 static const uint8_t expected_thresholds[] = { 0, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 2, 2, 2, 2 };
439 for (
uint64_t h = 0; h <
sizeof(block_versions) /
sizeof(block_versions[0]); ++h) {
445 ASSERT_EQ(std::min<uint64_t>(h, 4), votes);
449 ASSERT_EQ(std::min<uint64_t>(h <= 3 ? 0 : h - 3, 4), votes);
453 ASSERT_EQ(std::min<uint64_t>(h <= 8 ? 0 : h - 8, 4), votes);
457 ASSERT_EQ(std::min<uint64_t>(h <= 14 ? 0 : h - 14, 4), votes);
460 ASSERT_EQ(std::min<uint64_t>(h, 4), window);
464 db.add_block(mkblock(hf, h, block_versions[h]), 0, 0, 0, 0, 0,
crypto::hash());
bool get_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint64_t &earliest_height, uint8_t &voting) const
returns information about current voting state