Skip to content

Commit

Permalink
Add a test for proposal policy change corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
linh2931 committed Aug 6, 2024
1 parent 7a8aa0b commit 787df05
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions unittests/producer_schedule_savanna_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,36 @@ BOOST_AUTO_TEST_CASE( switch_producers_test ) try {

} FC_LOG_AND_RETHROW()

// This is to verify the bug reported by https://github.com/AntelopeIO/spring/issues/454
// is fixed.
BOOST_FIXTURE_TEST_CASE( policy_switching_corner_case_test, validating_tester ) try {
// With regular validating_tester, we have already transitioned into Savanna

// In round 1, a block proposes a proposer policy.
create_accounts( {"alice"_n} );
set_producers( {"alice"_n} );
auto b = produce_block();
auto index = b->timestamp.slot % config::producer_repetitions; // current index in current round
produce_blocks(config::producer_repetitions - index - 1); // to end of the round

// In round 2, the block in the last time slot of the round is not present.
produce_blocks(config::producer_repetitions - 1);
const auto time_to_skip = fc::milliseconds(config::block_interval_ms);
produce_block(time_to_skip); // Leave the last block empty

// In round 3, there exists at least one block.
produce_block(); // the first block of round 3

// Now alice's schedule should become active
vector<producer_authority> alice_sch = {
producer_authority{
"alice"_n,
block_signing_authority_v0{
1,
{{get_public_key("alice"_n, "active"), 1}}}}
};
BOOST_CHECK_EQUAL(control->active_producers().version, 1u);
BOOST_CHECK_EQUAL(compare_schedules(alice_sch, control->active_producers()), true);
} FC_LOG_AND_RETHROW()

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 787df05

Please sign in to comment.