Electroneum
Loading...
Searching...
No Matches
chaingen_main.cpp File Reference
#include "chaingen.h"
#include "chaingen_tests_list.h"
#include "common/util.h"
#include "common/command_line.h"
#include "transaction_tests.h"
Include dependency graph for chaingen_main.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 51 of file chaingen_main.cpp.

52{
53 TRY_ENTRY();
56
57 //set up logging options
58 mlog_configure(mlog_get_default_log_path("core_tests.log"), true);
60
61 po::options_description desc_options("Allowed options");
63 command_line::add_arg(desc_options, arg_test_data_path);
64 command_line::add_arg(desc_options, arg_generate_test_data);
65 command_line::add_arg(desc_options, arg_play_test_data);
66 command_line::add_arg(desc_options, arg_generate_and_play_test_data);
67 command_line::add_arg(desc_options, arg_test_transactions);
68 command_line::add_arg(desc_options, arg_filter);
69 command_line::add_arg(desc_options, arg_list_tests);
70
71 po::variables_map vm;
72 bool r = command_line::handle_error_helper(desc_options, [&]()
73 {
74 po::store(po::parse_command_line(argc, argv, desc_options), vm);
75 po::notify(vm);
76 return true;
77 });
78 if (!r)
79 return 1;
80
82 {
83 std::cout << desc_options << std::endl;
84 return 0;
85 }
86
87 const std::string filter = tools::glob_to_regex(command_line::get_arg(vm, arg_filter));
88 boost::smatch match;
89
90 size_t tests_count = 0;
91 std::vector<std::string> failed_tests;
92 std::string tests_folder = command_line::get_arg(vm, arg_test_data_path);
93 bool list_tests = false;
94 if (command_line::get_arg(vm, arg_generate_test_data))
95 {
96 GENERATE("chain001.dat", gen_simple_chain_001);
97 }
98 else if (command_line::get_arg(vm, arg_play_test_data))
99 {
100 PLAY("chain001.dat", gen_simple_chain_001);
101 }
102 else if (command_line::get_arg(vm, arg_generate_and_play_test_data) || (list_tests = command_line::get_arg(vm, arg_list_tests)))
103 {
110 //GENERATE_AND_PLAY(gen_ring_signature_big); // Takes up to XXX hours (if CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW == 10)
111
112 // Block verification tests
136 GENERATE_AND_PLAY(gen_block_invalid_binary_format); // Takes up to 3 hours, if CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW == 500, up to 30 minutes, if CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW == 10
137
138 // Transaction verification tests
157
158 // Double spend
170
171// GENERATE_AND_PLAY(gen_uint_overflow_1);
172// GENERATE_AND_PLAY(gen_uint_overflow_2);
173
175
178// GENERATE_AND_PLAY(gen_v2_tx_unmixable_only);
179// GENERATE_AND_PLAY(gen_v2_tx_unmixable_one);
180// GENERATE_AND_PLAY(gen_v2_tx_unmixable_two);
182
211
240
256
257 el::Level level = (failed_tests.empty() ? el::Level::Info : el::Level::Error);
258 if (!list_tests)
259 {
260 MLOG(level, "\nREPORT:");
261 MLOG(level, " Test run: " << tests_count);
262 MLOG(level, " Failures: " << failed_tests.size());
263 }
264 if (!failed_tests.empty())
265 {
266 MLOG(level, "FAILED TESTS:");
267 BOOST_FOREACH(auto test_name, failed_tests)
268 {
269 MLOG(level, " " << test_name);
270 }
271 }
272 }
273 else if (command_line::get_arg(vm, arg_test_transactions))
274 {
275 CALL_TEST("TRANSACTIONS TESTS", test_transactions);
276 }
277 else
278 {
279 MERROR("Wrong arguments");
280 return 2;
281 }
282
283 return failed_tests.empty() ? 0 : 1;
284
285 CATCH_ENTRY_L0("main", 1);
286}
#define GENERATE_AND_PLAY(genclass)
Definition chaingen.h:1013
#define CALL_TEST(test_name, function)
Definition chaingen.h:1042
#define GENERATE(filename, genclass)
Definition chaingen.h:953
#define PLAY(filename, genclass)
Definition chaingen.h:966
#define MERROR(x)
Definition misc_log_ex.h:73
void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size=MAX_LOG_FILE_SIZE, const std::size_t max_log_files=MAX_LOG_FILES)
Definition mlog.cpp:148
std::string mlog_get_default_log_path(const char *default_filename)
Definition mlog.cpp:72
void mlog_set_log_level(int level)
Definition mlog.cpp:282
#define MLOG(level, x)
Definition misc_log_ex.h:78
#define CATCH_ENTRY_L0(lacation, return_val)
#define TRY_ENTRY()
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)
const arg_descriptor< bool > arg_help
bool handle_error_helper(const boost::program_options::options_description &desc, F parser)
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
Level
Represents enumeration for severity level used to determine level of logging.
@ Info
Mainly useful to represent current progress of application.
@ Error
Information representing errors in application but application will keep running.
bool set_module_name_and_folder(const std::string &path_to_process_)
std::string glob_to_regex(const std::string &val)
Definition util.cpp:1012
bool on_startup()
Definition util.cpp:778
bool test_transactions()
Here is the call graph for this function: