17void initialize_system()
22std::string GetArgumentName(
const std::string& name)
24 size_t idx = name.find(
'=');
25 if (idx == std::string::npos) {
28 return name.substr(0, idx);
35 std::vector<std::string> command_option_names;
37 if (fuzzed_data_provider.ConsumeBool()) {
48 auto str_arg = fuzzed_data_provider.ConsumeRandomLengthString(16);
49 auto str_value = fuzzed_data_provider.ConsumeRandomLengthString(16);
53 auto str_arg = fuzzed_data_provider.ConsumeRandomLengthString(16);
54 auto str_value = fuzzed_data_provider.ConsumeRandomLengthString(16);
58 auto str_arg = fuzzed_data_provider.ConsumeRandomLengthString(16);
59 auto f_value = fuzzed_data_provider.ConsumeBool();
63 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::COMMAND_OPTIONS,
OptionsCategory::HIDDEN});
66 const std::string argument_name = GetArgumentName(fuzzed_data_provider.ConsumeRandomLengthString(16));
67 if (args_manager.
GetArgFlags(argument_name) != std::nullopt) {
70 auto help = fuzzed_data_provider.ConsumeRandomLengthString(16);
72 args_manager.
AddArg(argument_name, help, flags, options_category);
74 command_option_names.push_back(argument_name);
78 auto cmd = fuzzed_data_provider.ConsumeRandomLengthString(16);
79 if (
cmd.empty() ||
cmd[0] ==
'-' ||
cmd.find(
'=') != std::string::npos)
return;
81 auto help = fuzzed_data_provider.ConsumeRandomLengthString(16);
82 std::set<std::string> options;
83 for (
const auto& opt : command_option_names) {
84 if (fuzzed_data_provider.ConsumeBool()) {
94 std::vector<std::string> hidden_arguments;
95 for (
const std::string& name : names) {
96 const std::string hidden_argument = GetArgumentName(name);
97 if (args_manager.
GetArgFlags(hidden_argument) != std::nullopt) {
100 if (std::find(hidden_arguments.begin(), hidden_arguments.end(), hidden_argument) != hidden_arguments.end()) {
103 hidden_arguments.push_back(hidden_argument);
109 command_option_names.clear();
113 std::vector<const char*> argv;
114 argv.reserve(random_arguments.size());
115 for (
const std::string& random_argument : random_arguments) {
116 argv.push_back(random_argument.c_str());
121 }
catch (
const std::logic_error&) {
126 const std::string s1 = fuzzed_data_provider.ConsumeRandomLengthString(16);
127 const std::string s2 = fuzzed_data_provider.ConsumeRandomLengthString(16);
128 const int64_t i64 = fuzzed_data_provider.ConsumeIntegral<int64_t>();
129 const bool b = fuzzed_data_provider.ConsumeBool();
132 (void)args_manager.
GetArg(s1, s2);
134 (void)args_manager.
GetArgs(s1);
138 }
catch (
const std::runtime_error&) {
bool HelpRequested(const ArgsManager &args)
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
bool ParseParameters(int argc, const char *const argv[], std::string &error) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
std::vector< std::string > GetArgs(const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return a vector of strings of the given argument.
std::list< SectionInfo > GetUnrecognizedSections() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Log warnings for unrecognized section names in the config file.
bool CheckCommandOptions(const std::string &command, std::vector< std::string > *errors=nullptr) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Check that any command-specific options the user specified are valid for the given command.
void AddCommand(const std::string &cmd, const std::string &help, std::set< std::string > options={}) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Add command.
bool SoftSetArg(const std::string &strArg, const std::string &strValue) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Set an argument if it doesn't already have a value.
std::set< std::string > GetUnsuitableSectionOnlyArgs() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Log warnings for options in m_section_only_args when they are specified in the default section but no...
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Add argument.
void ForceSetArg(const std::string &strArg, const std::string &strValue) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
std::string GetArg(const std::string &strArg, const std::string &strDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return string argument or default value.
void AddHiddenArgs(const std::vector< std::string > &args) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Add many hidden arguments.
std::string GetChainTypeString() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Returns the appropriate chain type string from the program arguments.
void ClearArgs() EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Clear available arguments.
bool IsArgSet(const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return true if the given argument has been manually set.
std::optional< const Command > GetCommand() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Get the command and command args (returns std::nullopt if no command provided).
bool SoftSetBoolArg(const std::string &strArg, bool fValue) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Set a boolean argument if it doesn't already have a value.
bool IsArgNegated(const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return true if the argument was originally passed as a negated option, i.e.
std::optional< unsigned int > GetArgFlags(const std::string &name) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return Flags for known arg.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
bool GetBoolArg(const std::string &strArg, bool fDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return boolean argument or default value.
void SelectConfigNetwork(const std::string &network) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Select the network in use.
std::string GetHelpMessage() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Get the help string.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
std::unique_ptr< T > MakeNoLogFileContext(const ChainType chain_type=ChainType::REGTEST, TestOpts opts={})
Make a test setup that has disk access to the debug.log file disabled.
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