Skip to content

Commit

Permalink
GH-37 Rename variable to make clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jan 9, 2024
1 parent cae6ac4 commit 889d3e9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 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->active_producers();
BOOST_REQUIRE_EQUAL( 21, producer_keys.producers.size() );
BOOST_REQUIRE_EQUAL( name("defproducera"), producer_keys.producers[0].producer_name );
auto producer_schedule = control->active_producers();
BOOST_REQUIRE_EQUAL( 21, producer_schedule.producers.size() );
BOOST_REQUIRE_EQUAL( name("defproducera"), producer_schedule.producers[0].producer_name );

return producer_names;
}
Expand Down
34 changes: 17 additions & 17 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->active_producers();
BOOST_REQUIRE_EQUAL( 1, producer_keys.producers.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys.producers[0].producer_name );
auto producer_schedule = control->active_producers();
BOOST_REQUIRE_EQUAL( 1, producer_schedule.producers.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_schedule.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,37 +3203,37 @@ 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->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 );
producer_schedule = control->active_producers();
BOOST_REQUIRE_EQUAL( 2, producer_schedule.producers.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_schedule.producers[0].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer2"), producer_schedule.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->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 );
producer_schedule = control->active_producers();
BOOST_REQUIRE_EQUAL( 3, producer_schedule.producers.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_schedule.producers[0].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer2"), producer_schedule.producers[1].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer3"), producer_schedule.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->active_producers();
BOOST_REQUIRE_EQUAL( 3, producer_keys.producers.size() );
producer_schedule = control->active_producers();
BOOST_REQUIRE_EQUAL( 3, producer_schedule.producers.size() );

// The test below is invalid now, producer schedule is not updated if there are
// fewer producers in the new schedule
/*
BOOST_REQUIRE_EQUAL( 2, producer_keys.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys[0].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer3"), producer_keys[1].producer_name );
BOOST_REQUIRE_EQUAL( 2, producer_schedule.size() );
BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_schedule[0].producer_name );
BOOST_REQUIRE_EQUAL( name("defproducer3"), producer_schedule[1].producer_name );
//config = config_to_variant( control->get_global_properties().configuration );
//auto prod3_config = testing::filter_fields( config, producer_parameters_example( 3 ) );
//REQUIRE_EQUAL_OBJECTS(prod3_config, config);
Expand Down

0 comments on commit 889d3e9

Please sign in to comment.