message: Add test to check producers account authority when a new set of producers are elected
diff: @@ -82,4 +82,62 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, testing_fixture)
  } FC_LOG_AND_RETHROW() }
  +//Check correct authority when new set of producers are elected
  +BOOST_FIXTURE_TEST_CASE(producers_authority, testing_fixture)
  +{ try {
  +
  + Make_Blockchain(chain)
  + chain.produce_blocks();
  +
  + Make_Account(chain, alice);
  + Make_Account(chain, bob);
  + Make_Account(chain, charlie);
  +
  + Make_Account(chain, newproducer1); Make_Producer(chain, newproducer1);
  + Make_Account(chain, newproducer2); Make_Producer(chain, newproducer2);
  + Make_Account(chain, newproducer3); Make_Producer(chain, newproducer3);
  +
  + Approve_Producer(chain, alice, newproducer1, true);
  + Approve_Producer(chain, bob, newproducer2, true);
  + Approve_Producer(chain, charlie, newproducer3, true);
  +
  + chain.produce_blocks(config::BlocksPerRound - chain.head_block_num() );
  +
  + auto& gpo = chain_db.get<global_property_object>();
  +
  + BOOST_REQUIRE(boost::find(gpo.active_producers, "newproducer1") != gpo.active_producers.end());
  + BOOST_REQUIRE(boost::find(gpo.active_producers, "newproducer2") != gpo.active_producers.end());
  + BOOST_REQUIRE(boost::find(gpo.active_producers, "newproducer3") != gpo.active_producers.end());
  +
  + auto threshold = uint32_t(gpo.active_producers.size()*config::ProducersAuthorityThreshold);
  +
  + const auto& producers_active_authority = chain_db.get<permission_object, by_owner>(boost::make_tuple(config::ProducersAccountName, config::ActiveName));
  + BOOST_CHECK_EQUAL(producers_active_authority.auth.threshold, threshold);
  + BOOST_CHECK_EQUAL(producers_active_authority.auth.accounts.size(), gpo.active_producers.size());
  + BOOST_CHECK_EQUAL(producers_active_authority.auth.keys.size(), 0);
  +
  + std::vector<AccountName> active_auth;
  + for(auto& apw : producers_active_authority.auth.accounts) {
  + active_auth.emplace_back(apw.permission.account);
  + }
  +
  + std::vector<AccountName> diff;
  + std::set_difference(
  + active_auth.begin(),
  + active_auth.end(),
  + gpo.active_producers.begin(),
  + gpo.active_producers.end(),
  + std::inserter(diff, diff.begin())
  + );
  +
  + BOOST_CHECK_EQUAL(diff.size(), 0);
  +
  + const auto& producers_owner_authority = chain_db.get<permission_object, by_owner>(boost::make_tuple(config::ProducersAccountName, config::OwnerName));
  + BOOST_CHECK_EQUAL(producers_owner_authority.auth.threshold, 0);
  + BOOST_CHECK_EQUAL(producers_owner_authority.auth.accounts.size(), 0);
  + BOOST_CHECK_EQUAL(producers_owner_authority.auth.keys.size(), 0);
  +
  +} FC_LOG_AND_RETHROW() }
  +
  +
  BOOST_AUTO_TEST_SUITE_END()
  