16void initialize_system()
18 static const auto testing_setup = MakeNoLogFileContext<>();
21std::string GetArgumentName(
const std::string&
name)
23 size_t idx =
name.find(
'=');
24 if (idx == std::string::npos) {
27 return name.substr(0, idx);
35 if (fuzzed_data_provider.ConsumeBool()) {
44 args_manager.SelectConfigNetwork(fuzzed_data_provider.ConsumeRandomLengthString(16));
47 auto str_arg = fuzzed_data_provider.ConsumeRandomLengthString(16);
48 auto str_value = fuzzed_data_provider.ConsumeRandomLengthString(16);
49 args_manager.SoftSetArg(str_arg, str_value);
52 auto str_arg = fuzzed_data_provider.ConsumeRandomLengthString(16);
53 auto str_value = fuzzed_data_provider.ConsumeRandomLengthString(16);
54 args_manager.ForceSetArg(str_arg, str_value);
57 auto str_arg = fuzzed_data_provider.ConsumeRandomLengthString(16);
58 auto f_value = fuzzed_data_provider.ConsumeBool();
59 args_manager.SoftSetBoolArg(str_arg, f_value);
62 const OptionsCategory options_category = fuzzed_data_provider.PickValueInArray<
OptionsCategory>({
OptionsCategory::OPTIONS,
OptionsCategory::CONNECTION,
OptionsCategory::WALLET,
OptionsCategory::WALLET_DEBUG_TEST,
OptionsCategory::ZMQ,
OptionsCategory::DEBUG_TEST,
OptionsCategory::CHAINPARAMS,
OptionsCategory::NODE_RELAY,
OptionsCategory::BLOCK_CREATION,
OptionsCategory::RPC,
OptionsCategory::GUI,
OptionsCategory::COMMANDS,
OptionsCategory::REGISTER_COMMANDS,
OptionsCategory::CLI_COMMANDS,
OptionsCategory::IPC,
OptionsCategory::HIDDEN});
65 const std::string argument_name = GetArgumentName(fuzzed_data_provider.ConsumeRandomLengthString(16));
66 if (args_manager.GetArgFlags(argument_name) != std::nullopt) {
69 auto help = fuzzed_data_provider.ConsumeRandomLengthString(16);
71 args_manager.AddArg(argument_name,
help,
flags, options_category);
77 std::vector<std::string> hidden_arguments;
78 for (
const std::string&
name : names) {
79 const std::string hidden_argument = GetArgumentName(
name);
80 if (args_manager.GetArgFlags(hidden_argument) != std::nullopt) {
83 if (std::find(hidden_arguments.begin(), hidden_arguments.end(), hidden_argument) != hidden_arguments.end()) {
86 hidden_arguments.push_back(hidden_argument);
88 args_manager.AddHiddenArgs(hidden_arguments);
91 args_manager.ClearArgs();
95 std::vector<const char*> argv;
96 argv.reserve(random_arguments.size());
97 for (
const std::string& random_argument : random_arguments) {
98 argv.push_back(random_argument.c_str());
102 (void)args_manager.ParseParameters(argv.size(), argv.data(), error);
103 }
catch (
const std::logic_error&) {
108 const std::string s1 = fuzzed_data_provider.ConsumeRandomLengthString(16);
109 const std::string s2 = fuzzed_data_provider.ConsumeRandomLengthString(16);
110 const int64_t i64 = fuzzed_data_provider.ConsumeIntegral<int64_t>();
111 const bool b = fuzzed_data_provider.ConsumeBool();
113 (void)args_manager.GetIntArg(s1, i64);
114 (void)args_manager.GetArg(s1, s2);
115 (void)args_manager.GetArgFlags(s1);
116 (void)args_manager.GetArgs(s1);
117 (void)args_manager.GetBoolArg(s1, b);
119 (void)args_manager.GetChainTypeString();
120 }
catch (
const std::runtime_error&) {
122 (void)args_manager.GetHelpMessage();
123 (void)args_manager.GetUnrecognizedSections();
124 (void)args_manager.GetUnsuitableSectionOnlyArgs();
125 (void)args_manager.IsArgNegated(s1);
126 (void)args_manager.IsArgSet(s1);
bool HelpRequested(const ArgsManager &args)
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
std::vector< std::string > ConsumeRandomLengthStringVector(FuzzedDataProvider &fuzzed_data_provider, const size_t max_vector_size=16, const size_t max_string_length=16) noexcept