0

i get the an error from the eosio.contract unit_test as follow:

/eosio/1.8/include/eosio/testing/tester.hpp(364): fatal error: in 
"eosio_system_tests/vote_producers_in_and_out": critical check 
validate() == true has failed [false != true]
terminate called after throwing an instance of 
'boost::execution_aborted'
unknown location(0): fatal error: in 
"eosio_system_tests/vote_producers_in_and_out": signal: SIGABRT 
(application abort requested)
/eosio/1.8/include/eosio/testing/tester.hpp(364): last checkpoint

What I did:

  1. created a second eosio_global_state table (copy&paste) and named it eosio_global_state5 (any other name will also do) and added/changed all the other necessary lines in eosio.system.hpp and eosio.system.cpp (but should also work with any other self created table which should be singleton and global)
  2. changed the unit_test eosio.system_tests.cpp vote_producers_in_and_out so that after the first vote for 21bps the bps produce few blocks and than change all bps at once and than produce a few blocks and here I get the error

and the error only comes when added the extra singleton global table. I I out comment the changes everything works fine again.

code table:

    struct [[eosio::table("global5"), eosio::contract("eosio.system")]] eosio_global_state5 {
    eosio_global_state5(){}

    uint64_t             max_ram_size = 64ll*1024 * 1024 * 1024;
    uint64_t             total_ram_bytes_reserved = 0;
    int64_t              total_ram_stake = 0;

    block_timestamp      last_producer_schedule_update;
    time_point           last_pervote_bucket_fill;
    int64_t              pervote_bucket = 0;
    int64_t              perblock_bucket = 0;
    uint32_t             total_unpaid_blocks = 0; /// all blocks which have been produced but not paid
    int64_t              total_activated_stake = 0;

    time_point           thresh_activated_stake_time;
    uint16_t             last_producer_schedule_size = 0;
    double               total_producer_vote_weight = 0; /// the sum of all producer votes
    block_timestamp      last_name_close;

    // explicit serialization macro is not necessary, used here only to improve compilation time
    EOSLIB_SERIALIZE( eosio_global_state5,
    (max_ram_size)(total_ram_bytes_reserved)(total_ram_stake)
            (last_producer_schedule_update)(last_pervote_bucket_fill)
            (pervote_bucket)(perblock_bucket)(total_unpaid_blocks)(total_activated_stake)(thresh_activated_stake_time)
            (last_producer_schedule_size)(total_producer_vote_weight)(last_name_close) )
};

code:

BOOST_FIXTURE_TEST_CASE( vote_producers_in_and_out, 
eosio_system_tester ) try {

const asset net = core_sym::from_string("80.0000");
const asset cpu = core_sym::from_string("80.0000");
std::vector<account_name> voters = { N(producvotera), N(producvoterb), 
N(producvoterc), N(producvoterd) };
for (const auto& v: voters) {
  create_account_with_resources(v, config::system_account_name, 
  core_sym::from_string("1.0000"), false, net, cpu);
}

// create accounts {defproducera, defproducerb, ..., defproducerz} and 
register as producers
std::vector<account_name> producer_names;
{
 producer_names = {"aaaaa1111111", "aaaaa1111112", "aaaaa1111113", 
 "aaaaa1111114", "aaaaa1111115", "bbb111111111",
                  "bbb111111112", "bbb111111113", "bbb111111114", 
 "bbb111111115", "cccc11111111", "cccc11111112",
                  "cccc11111113", "cccc11111114", "cccc11111115", 
 "dddd11111111", "dddd11111112", "defproducera",
                  "defproducerb", "defproducerc", "defproducerd", 
 "defproducere", "defproducerf", "defproducerg",
                  "defproducerh", "defproduceri", "defproducerj", 
 "defproducerk", "defproducerl", "defproducerm",
                  "defproducern", "defproducero", "defproducerp", 
 "defproducerq", "defproducerr", "defproducers",
                  "defproducert", "defproduceru", "defproducerv", 
 "defproducerw", "defproducerx", "defproducery",
                  "defproducerz", "defproducesa", "defproducesb"};
  setup_producer_accounts(producer_names);
  for (const auto& p: producer_names) {
     BOOST_REQUIRE_EQUAL( success(), regproducer(p) );
     produce_blocks(1);
     ilog( "------ get pro----------" );
     wdump((p));
     BOOST_TEST(0 == get_producer_info(p)["total_votes"].as<double> 
 ());
  }
}

for (const auto& v: voters) {
  transfer( config::system_account_name, v, 
  core_sym::from_string("200000000.0000"), config::system_account_name 
 );
  BOOST_REQUIRE_EQUAL(success(), stake(v, core_sym::from_string("30000000.0000"), core_sym::from_string("30000000.0000")) );
}

{
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvotera), vector<account_name>(producer_names.begin(), producer_names.begin()+20)));
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterb), vector<account_name>(producer_names.begin(), producer_names.begin()+21)));
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterc), vector<account_name>(producer_names.begin(), producer_names.begin()+5)));
  produce_blocks(23 * 12 + 20);
}

// give a chance for everyone to produce blocks
{
  produce_blocks(23 * 12 + 20);
  bool all_21_produced = true;
  for (uint32_t i = 0; i < 21; ++i) {
     if (0 == get_producer_info(producer_names[i])["unpaid_blocks"].as<uint32_t>()) {
        all_21_produced = false;
     }
  }
  bool rest_didnt_produce = true;
  for (uint32_t i = 21; i < producer_names.size(); ++i) {
     if (0 < get_producer_info(producer_names[i])["unpaid_blocks"].as<uint32_t>()) {
        rest_didnt_produce = false;
     }
  }
  BOOST_REQUIRE(all_21_produced && rest_didnt_produce);
}


{
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvotera), vector<account_name>(producer_names.begin()+22, producer_names.begin()+44)));
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterb), vector<account_name>(producer_names.begin()+22, producer_names.begin()+44)));
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterc), vector<account_name>(producer_names.begin()+15, producer_names.begin()+20)));
  produce_blocks(1000);
}


{
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvotera), vector<account_name>(producer_names.begin(), producer_names.begin()+21)));
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterb), vector<account_name>(producer_names.begin(), producer_names.begin()+21)));
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterc), vector<account_name>(producer_names.begin(), producer_names.begin()+5)));
  produce_blocks(1000);
}

{
  produce_block(fc::hours(7));
  const uint32_t voted_out_index = 20;
  const uint32_t new_prod_index  = 23;
  BOOST_REQUIRE_EQUAL(success(), stake("producvoterd", core_sym::from_string("40000000.0000"), core_sym::from_string("40000000.0000")));
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterd), { producer_names[new_prod_index] }));
  BOOST_REQUIRE_EQUAL(0, get_producer_info(producer_names[new_prod_index])["unpaid_blocks"].as<uint32_t>());
  produce_blocks(4 * 12 * 21);
  BOOST_REQUIRE(0 < get_producer_info(producer_names[new_prod_index])["unpaid_blocks"].as<uint32_t>());
  const uint32_t initial_unpaid_blocks = get_producer_info(producer_names[voted_out_index])["unpaid_blocks"].as<uint32_t>();
  produce_blocks(2 * 12 * 21);
  BOOST_REQUIRE_EQUAL(initial_unpaid_blocks, get_producer_info(producer_names[voted_out_index])["unpaid_blocks"].as<uint32_t>());
  produce_block(fc::hours(24));
  BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterd), { producer_names[voted_out_index] }));
  produce_blocks(2 * 12 * 21);
  BOOST_REQUIRE(fc::crypto::public_key() != fc::crypto::public_key(get_producer_info(producer_names[voted_out_index])["producer_key"].as_string()));
  BOOST_REQUIRE_EQUAL(success(), push_action(producer_names[voted_out_index], N(claimrewards), mvo()("owner", producer_names[voted_out_index])));
 }

 } FC_LOG_AND_RETHROW()

my questions are now:

  1. is it a general error from eosio software or just the test enviroment
  2. what do I need to change, so i can add my own global singleton tables and the test will be correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.