diff --git a/CMakeLists.txt b/CMakeLists.txt index e8fb0eeab364139987e09187acefb57e9650fceb..3a205543d83d69bf5f209a00b2460266e767ddf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -187,7 +187,7 @@ add_subdirectory( contracts ) add_subdirectory( plugins ) add_subdirectory( programs ) add_subdirectory( scripts ) -#add_subdirectory( tests ) +add_subdirectory( tests ) add_subdirectory( unittests ) add_subdirectory( tools ) add_subdirectory( debian ) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 40fabd532eb504f3b453f005fbd73dcd822abca3..455e9218b7eb15f98946a51a64cf64b2370900f2 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -284,8 +284,8 @@ struct controller_impl { authority system_auth(conf.genesis.initial_key); create_native_account( config::system_account_name, system_auth, system_auth, true ); - auto empty_authority = authority(0, {}, {}); - auto active_producers_authority = authority(0, {}, {}); + auto empty_authority = authority(1, {}, {}); + auto active_producers_authority = authority(1, {}, {}); active_producers_authority.accounts.push_back({{config::system_account_name, config::active_name}, 1}); create_native_account( config::nobody_account_name, empty_authority, empty_authority ); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 18ea6c7994840c7292a38d8c3bf164559fa3a725..99fb6db4a4ee5d07f8c358a74a4ff37e45cf8f19 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,7 +18,9 @@ include_directories("${CMAKE_SOURCE_DIR}/plugins/wallet_plugin/include") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/config.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/tests/config.hpp ESCAPE_QUOTES) -file(GLOB UNIT_TESTS "chain_tests/*.cpp" "api_tests/*.cpp" "wasm_tests/*.cpp" "tests/message_buffer_tests.cpp" "tests/special_accounts_tests.cpp" "tests/wallet_tests.cpp" "library_tests/*/*.cpp") +# Temporarily remove some tests to get chain_test to compile +#file(GLOB UNIT_TESTS "chain_tests/*.cpp" "api_tests/*.cpp" "wasm_tests/*.cpp") +file(GLOB UNIT_TESTS "api_tests/*.cpp") add_executable( chain_test ${UNIT_TESTS} ${WASM_UNIT_TESTS} common/main.cpp) target_link_libraries( chain_test eosio_testing eosio_chain chainbase eos_utilities chain_plugin wallet_plugin abi_generator fc ${PLATFORM_SPECIFIC_LIBS} ) diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index c17c7407a71a5b7e2afc8908f7f756c41806cd43..525efa83cf9c2a3eed47b5561d666fedeb6385ca 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -16,6 +16,7 @@ include_directories("${CMAKE_BINARY_DIR}/contracts") include_directories("${CMAKE_SOURCE_DIR}/contracts") include_directories("${CMAKE_SOURCE_DIR}/libraries/testing/include") include_directories("${CMAKE_SOURCE_DIR}/plugins/chain_plugin/include") +include_directories("${CMAKE_SOURCE_DIR}/plugins/wallet_plugin/include") include_directories("${CMAKE_SOURCE_DIR}/libraries/appbase/include") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/config.hpp ESCAPE_QUOTES) @@ -23,7 +24,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in ${CMAKE_CURRENT_SOURCE_ file(GLOB UNIT_TESTS "*.cpp") add_executable( unit_test ${UNIT_TESTS} ${WASM_UNIT_TESTS} ) -target_link_libraries( unit_test eosio_chain chainbase eosio_testing eos_utilities abi_generator fc ${PLATFORM_SPECIFIC_LIBS} ) +target_link_libraries( unit_test eosio_chain chainbase eosio_testing eos_utilities chain_plugin wallet_plugin abi_generator fc ${PLATFORM_SPECIFIC_LIBS} ) target_include_directories( unit_test PUBLIC ${CMAKE_BINARY_DIR}/contracts ${CMAKE_CURRENT_BINARY_DIR}/tests/contracts ) target_include_directories( unit_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/wasm_tests ) diff --git a/tests/tests/special_accounts_tests.cpp b/unittests/special_accounts_tests.cpp similarity index 79% rename from tests/tests/special_accounts_tests.cpp rename to unittests/special_accounts_tests.cpp index 916e56832d7cd9f714eb211e14fd53ee121212e1..a266a483a93c547c946719eb1ab351d615564d98 100644 --- a/tests/tests/special_accounts_tests.cpp +++ b/unittests/special_accounts_tests.cpp @@ -7,9 +7,10 @@ #include #include -#include +#include #include #include +#include #include @@ -33,30 +34,30 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, tester) { try { tester test; - chain::chain_controller *control = test.control.get(); - chain::database &chain1_db = control->get_mutable_database(); + chain::controller *control = test.control.get(); + chain::database &chain1_db = control->db(); auto nobody = chain1_db.find(config::nobody_account_name); BOOST_CHECK(nobody != nullptr); const auto& nobody_active_authority = chain1_db.get(boost::make_tuple(config::nobody_account_name, config::active_name)); - BOOST_CHECK_EQUAL(nobody_active_authority.auth.threshold, 0); + BOOST_CHECK_EQUAL(nobody_active_authority.auth.threshold, 1); BOOST_CHECK_EQUAL(nobody_active_authority.auth.accounts.size(), 0); BOOST_CHECK_EQUAL(nobody_active_authority.auth.keys.size(), 0); const auto& nobody_owner_authority = chain1_db.get(boost::make_tuple(config::nobody_account_name, config::owner_name)); - BOOST_CHECK_EQUAL(nobody_owner_authority.auth.threshold, 0); + BOOST_CHECK_EQUAL(nobody_owner_authority.auth.threshold, 1); BOOST_CHECK_EQUAL(nobody_owner_authority.auth.accounts.size(), 0); BOOST_CHECK_EQUAL(nobody_owner_authority.auth.keys.size(), 0); auto producers = chain1_db.find(config::producers_account_name); BOOST_CHECK(producers != nullptr); - auto& gpo = chain1_db.get(); + const auto& active_producers = control->head_block_state()->active_schedule; const auto& producers_active_authority = chain1_db.get(boost::make_tuple(config::producers_account_name, config::active_name)); - auto expected_threshold = EOS_PERCENT_CEIL(gpo.active_producers.producers.size(), config::producers_authority_threshold_pct); + auto expected_threshold = EOS_PERCENT_CEIL(active_producers.producers.size(), config::producers_authority_threshold_pct); BOOST_CHECK_EQUAL(producers_active_authority.auth.threshold, expected_threshold); - BOOST_CHECK_EQUAL(producers_active_authority.auth.accounts.size(), gpo.active_producers.producers.size()); + BOOST_CHECK_EQUAL(producers_active_authority.auth.accounts.size(), active_producers.producers.size()); BOOST_CHECK_EQUAL(producers_active_authority.auth.keys.size(), 0); std::vector active_auth; @@ -65,16 +66,16 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, tester) } std::vector diff; - for (int i = 0; i < std::max(active_auth.size(), gpo.active_producers.producers.size()); ++i) { + for (int i = 0; i < std::max(active_auth.size(), active_producers.producers.size()); ++i) { account_name n1 = i < active_auth.size() ? active_auth[i] : (account_name)0; - account_name n2 = i < gpo.active_producers.producers.size() ? gpo.active_producers.producers[i].producer_name : (account_name)0; + account_name n2 = i < active_producers.producers.size() ? active_producers.producers[i].producer_name : (account_name)0; if (n1 != n2) diff.push_back((uint64_t)n2 - (uint64_t)n1); } BOOST_CHECK_EQUAL(diff.size(), 0); const auto& producers_owner_authority = chain1_db.get(boost::make_tuple(config::producers_account_name, config::owner_name)); - BOOST_CHECK_EQUAL(producers_owner_authority.auth.threshold, 0); + BOOST_CHECK_EQUAL(producers_owner_authority.auth.threshold, 1); BOOST_CHECK_EQUAL(producers_owner_authority.auth.accounts.size(), 0); BOOST_CHECK_EQUAL(producers_owner_authority.auth.keys.size(), 0); diff --git a/tests/tests/wallet_tests.cpp b/unittests/wallet_tests.cpp similarity index 100% rename from tests/tests/wallet_tests.cpp rename to unittests/wallet_tests.cpp