Skip to content

Commit

Permalink
GH-37 Update to use controller active_producers(0 instead of accessin…
Browse files Browse the repository at this point in the history
…g head_block_state.
  • Loading branch information
heifner committed Jan 5, 2024
1 parent 247b5c4 commit a3ee2ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions tests/eosio.system_tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,9 @@ class eosio_system_tester : public TESTER {
}
produce_blocks( 250 );

auto producer_keys = control->head_block_state()->active_schedule.producers;
BOOST_REQUIRE_EQUAL( 21, producer_keys.size() );
BOOST_REQUIRE_EQUAL( name("defproducera"), producer_keys[0].producer_name );
auto producer_keys = control->active_producers();
BOOST_REQUIRE_EQUAL( 21, producer_keys.producers.size() );
BOOST_REQUIRE_EQUAL( name("defproducera"), producer_keys.producers[0].producer_name );

return producer_names;
}
Expand Down
28 changes: 14 additions & 14 deletions tests/eosio.system_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3187,9 +3187,9 @@ BOOST_FIXTURE_TEST_CASE( elect_producers /*_and_parameters*/, eosio_system_teste
//vote for producers
BOOST_REQUIRE_EQUAL( success(), vote( "alice1111111"_n, { "defproducer1"_n } ) );
produce_blocks(250);
auto producer_keys = control->head_block_state()->active_schedule.producers;
BOOST_REQUIRE_EQUAL( 1, producer_keys.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys[0].producer_name );
auto producer_keys = control->active_producers();
BOOST_REQUIRE_EQUAL( 1, producer_keys.producers.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys.producers[0].producer_name );

//auto config = config_to_variant( control->get_global_properties().configuration );
//auto prod1_config = testing::filter_fields( config, producer_parameters_example( 1 ) );
Expand All @@ -3203,30 +3203,30 @@ BOOST_FIXTURE_TEST_CASE( elect_producers /*_and_parameters*/, eosio_system_teste
BOOST_REQUIRE_EQUAL( success(), vote( "bob111111111"_n, { "defproducer2"_n } ) );
ilog(".");
produce_blocks(250);
producer_keys = control->head_block_state()->active_schedule.producers;
BOOST_REQUIRE_EQUAL( 2, producer_keys.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys[0].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer2"), producer_keys[1].producer_name );
producer_keys = control->active_producers();
BOOST_REQUIRE_EQUAL( 2, producer_keys.producers.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys.producers[0].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer2"), producer_keys.producers[1].producer_name );
//config = config_to_variant( control->get_global_properties().configuration );
//auto prod2_config = testing::filter_fields( config, producer_parameters_example( 2 ) );
//REQUIRE_EQUAL_OBJECTS(prod2_config, config);

// elect 3 producers
BOOST_REQUIRE_EQUAL( success(), vote( "bob111111111"_n, { "defproducer2"_n, "defproducer3"_n } ) );
produce_blocks(250);
producer_keys = control->head_block_state()->active_schedule.producers;
BOOST_REQUIRE_EQUAL( 3, producer_keys.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys[0].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer2"), producer_keys[1].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer3"), producer_keys[2].producer_name );
producer_keys = control->active_producers();
BOOST_REQUIRE_EQUAL( 3, producer_keys.producers.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys.producers[0].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer2"), producer_keys.producers[1].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer3"), producer_keys.producers[2].producer_name );
//config = config_to_variant( control->get_global_properties().configuration );
//REQUIRE_EQUAL_OBJECTS(prod2_config, config);

// try to go back to 2 producers and fail
BOOST_REQUIRE_EQUAL( success(), vote( "bob111111111"_n, { "defproducer3"_n } ) );
produce_blocks(250);
producer_keys = control->head_block_state()->active_schedule.producers;
BOOST_REQUIRE_EQUAL( 3, producer_keys.size() );
producer_keys = control->active_producers();
BOOST_REQUIRE_EQUAL( 3, producer_keys.producers.size() );

// The test below is invalid now, producer schedule is not updated if there are
// fewer producers in the new schedule
Expand Down

0 comments on commit a3ee2ed

Please sign in to comment.