int main(int argc, char** argv) { epee::string_tools::set_module_name_and_folder(argv[0]); mlog_configure(mlog_get_default_log_path("unit_tests.log"), true); epee::debug::get_set_enable_assert(true, false); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
bool CurrentBlockchainStatus::init_monero_blockchain() { // set monero log output level uint32_t log_level = 0; mlog_configure(mlog_get_default_log_path(""), true); mcore = unique_ptr<xmreg::MicroCore>(new xmreg::MicroCore{}); // initialize the core using the blockchain path if (!mcore->init(blockchain_path)) { cerr << "Error accessing blockchain." << endl; return false; } // get the high level Blockchain object to interact // with the blockchain lmdb database core_storage = &(mcore->get_core()); return true; }
int main(int argc, char** argv) { set_process_affinity(1); set_thread_high_priority(); mlog_configure(mlog_get_default_log_path("performance_tests.log"), true); mlog_set_log_level(0); performance_timer timer; timer.start(); TEST_PERFORMANCE3(test_construct_tx, 1, 1, false); TEST_PERFORMANCE3(test_construct_tx, 1, 2, false); TEST_PERFORMANCE3(test_construct_tx, 1, 10, false); TEST_PERFORMANCE3(test_construct_tx, 1, 100, false); TEST_PERFORMANCE3(test_construct_tx, 1, 1000, false); TEST_PERFORMANCE3(test_construct_tx, 2, 1, false); TEST_PERFORMANCE3(test_construct_tx, 2, 2, false); TEST_PERFORMANCE3(test_construct_tx, 2, 10, false); TEST_PERFORMANCE3(test_construct_tx, 2, 100, false); TEST_PERFORMANCE3(test_construct_tx, 10, 1, false); TEST_PERFORMANCE3(test_construct_tx, 10, 2, false); TEST_PERFORMANCE3(test_construct_tx, 10, 10, false); TEST_PERFORMANCE3(test_construct_tx, 10, 100, false); TEST_PERFORMANCE3(test_construct_tx, 100, 1, false); TEST_PERFORMANCE3(test_construct_tx, 100, 2, false); TEST_PERFORMANCE3(test_construct_tx, 100, 10, false); TEST_PERFORMANCE3(test_construct_tx, 100, 100, false); TEST_PERFORMANCE3(test_construct_tx, 2, 1, true); TEST_PERFORMANCE3(test_construct_tx, 2, 2, true); TEST_PERFORMANCE3(test_construct_tx, 2, 10, true); TEST_PERFORMANCE3(test_construct_tx, 10, 1, true); TEST_PERFORMANCE3(test_construct_tx, 10, 2, true); TEST_PERFORMANCE3(test_construct_tx, 10, 10, true); TEST_PERFORMANCE3(test_construct_tx, 100, 1, true); TEST_PERFORMANCE3(test_construct_tx, 100, 2, true); TEST_PERFORMANCE3(test_construct_tx, 100, 10, true); TEST_PERFORMANCE2(test_check_tx_signature, 1, false); TEST_PERFORMANCE2(test_check_tx_signature, 2, false); TEST_PERFORMANCE2(test_check_tx_signature, 10, false); TEST_PERFORMANCE2(test_check_tx_signature, 100, false); TEST_PERFORMANCE2(test_check_tx_signature, 2, true); TEST_PERFORMANCE2(test_check_tx_signature, 10, true); TEST_PERFORMANCE2(test_check_tx_signature, 100, true); TEST_PERFORMANCE0(test_is_out_to_acc); TEST_PERFORMANCE0(test_generate_key_image_helper); TEST_PERFORMANCE0(test_generate_key_derivation); TEST_PERFORMANCE0(test_generate_key_image); TEST_PERFORMANCE0(test_derive_public_key); TEST_PERFORMANCE0(test_derive_secret_key); TEST_PERFORMANCE0(test_ge_frombytes_vartime); TEST_PERFORMANCE0(test_generate_keypair); TEST_PERFORMANCE0(test_sc_reduce32); TEST_PERFORMANCE0(test_cn_slow_hash); TEST_PERFORMANCE1(test_cn_fast_hash, 32); TEST_PERFORMANCE1(test_cn_fast_hash, 16384); std::cout << "Tests finished. Elapsed time: " << timer.elapsed_ms() / 1000 << " sec" << std::endl; return 0; }
std::pair<boost::optional<boost::program_options::variables_map>, bool> main( int argc, char** argv, const char* const usage, const char* const notice, boost::program_options::options_description desc_params, const boost::program_options::positional_options_description& positional_options, const std::function<void(const std::string&, bool)> &print, const char *default_log_name, bool log_to_console) { namespace bf = boost::filesystem; namespace po = boost::program_options; #ifdef WIN32 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif const command_line::arg_descriptor<std::string> arg_log_level = {"log-level", "0-4 or categories", ""}; const command_line::arg_descriptor<std::size_t> arg_max_log_file_size = {"max-log-file-size", "Specify maximum log file size [B]", MAX_LOG_FILE_SIZE}; const command_line::arg_descriptor<std::size_t> arg_max_log_files = {"max-log-files", "Specify maximum number of rotated log files to be saved (no limit by setting to 0)", MAX_LOG_FILES}; const command_line::arg_descriptor<uint32_t> arg_max_concurrency = {"max-concurrency", wallet_args::tr("Max number of threads to use for a parallel job"), DEFAULT_MAX_CONCURRENCY}; const command_line::arg_descriptor<std::string> arg_log_file = {"log-file", wallet_args::tr("Specify log file"), ""}; const command_line::arg_descriptor<std::string> arg_config_file = {"config-file", wallet_args::tr("Config file"), "", true}; std::string lang = i18n_get_language(); tools::on_startup(); tools::set_strict_default_file_permissions(true); epee::string_tools::set_module_name_and_folder(argv[0]); po::options_description desc_general(wallet_args::tr("General options")); command_line::add_arg(desc_general, command_line::arg_help); command_line::add_arg(desc_general, command_line::arg_version); command_line::add_arg(desc_params, arg_log_file); command_line::add_arg(desc_params, arg_log_level); command_line::add_arg(desc_params, arg_max_log_file_size); command_line::add_arg(desc_params, arg_max_log_files); command_line::add_arg(desc_params, arg_max_concurrency); command_line::add_arg(desc_params, arg_config_file); i18n_set_language("translations", "monero", lang); po::options_description desc_all; desc_all.add(desc_general).add(desc_params); po::variables_map vm; bool should_terminate = false; bool r = command_line::handle_error_helper(desc_all, [&]() { auto parser = po::command_line_parser(argc, argv).options(desc_all).positional(positional_options); po::store(parser.run(), vm); if (command_line::get_arg(vm, command_line::arg_help)) { Print(print) << "Aeon '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL; Print(print) << wallet_args::tr("This is the command line Aeon wallet. It needs to connect to a Aeon\n" "daemon to work correctly.") << ENDL; Print(print) << wallet_args::tr("Usage:") << ENDL << " " << usage; Print(print) << desc_all; should_terminate = true; return true; } else if (command_line::get_arg(vm, command_line::arg_version)) { Print(print) << "Aeon '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")"; should_terminate = true; return true; } if(command_line::has_arg(vm, arg_config_file)) { std::string config = command_line::get_arg(vm, arg_config_file); bf::path config_path(config); boost::system::error_code ec; if (bf::exists(config_path, ec)) { po::store(po::parse_config_file<char>(config_path.string<std::string>().c_str(), desc_params), vm); } else { MERROR(wallet_args::tr("Can't find config file ") << config); return false; } } po::notify(vm); return true; }); if (!r) return {boost::none, true}; if (should_terminate) return {std::move(vm), should_terminate}; std::string log_path; if (!command_line::is_arg_defaulted(vm, arg_log_file)) log_path = command_line::get_arg(vm, arg_log_file); else log_path = mlog_get_default_log_path(default_log_name); mlog_configure(log_path, log_to_console, command_line::get_arg(vm, arg_max_log_file_size), command_line::get_arg(vm, arg_max_log_files)); if (!command_line::is_arg_defaulted(vm, arg_log_level)) { mlog_set_log(command_line::get_arg(vm, arg_log_level).c_str()); } else if (!log_to_console) { mlog_set_categories(""); } if (notice) Print(print) << notice << ENDL; if (!command_line::is_arg_defaulted(vm, arg_max_concurrency)) tools::set_max_concurrency(command_line::get_arg(vm, arg_max_concurrency)); Print(print) << "Aeon '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")"; if (!command_line::is_arg_defaulted(vm, arg_log_level)) MINFO("Setting log level = " << command_line::get_arg(vm, arg_log_level)); else MINFO("Setting log levels = " << getenv("AEON_LOGS")); MINFO(wallet_args::tr("Logging to: ") << log_path); Print(print) << boost::format(wallet_args::tr("Logging to %s")) % log_path; return {std::move(vm), should_terminate}; }