mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-06 21:57:54 +02:00
tor, fuzz: reuse constants instead of duplicating
`src/torcontrol.cpp` used to define some constants that are used explicitly in `src/torcontrol.cpp` and implicitly in `src/test/fuzz/torcontrol.cpp` by duplicating their values. Move the constants to `src/torcontrol.h` and reuse them in `src/test/fuzz/torcontrol.cpp` to avoid duplication and magic numbers.
This commit is contained in:
@@ -49,10 +49,10 @@ FUZZ_TARGET(torcontrol, .init = initialize_torcontrol)
|
||||
CallOneOf(
|
||||
fuzzed_data_provider,
|
||||
[&] {
|
||||
tor_control_reply.code = 250;
|
||||
tor_control_reply.code = TOR_REPLY_OK;
|
||||
},
|
||||
[&] {
|
||||
tor_control_reply.code = 510;
|
||||
tor_control_reply.code = TOR_REPLY_UNRECOGNIZED;
|
||||
},
|
||||
[&] {
|
||||
tor_control_reply.code = fuzzed_data_provider.ConsumeIntegral<int>();
|
||||
|
||||
@@ -53,9 +53,6 @@ const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:" + ToString(DEFAULT_TOR_CONT
|
||||
static const int TOR_COOKIE_SIZE = 32;
|
||||
/** Size of client/server nonce for SAFECOOKIE */
|
||||
static const int TOR_NONCE_SIZE = 32;
|
||||
/** Tor control reply code. Ref: https://spec.torproject.org/control-spec/replies.html */
|
||||
static const int TOR_REPLY_OK = 250;
|
||||
static const int TOR_REPLY_UNRECOGNIZED = 510;
|
||||
/** For computing serverHash in SAFECOOKIE */
|
||||
static const std::string TOR_SAFE_SERVERKEY = "Tor safe cookie authentication server-to-controller hash";
|
||||
/** For computing clientHash in SAFECOOKIE */
|
||||
|
||||
@@ -24,6 +24,10 @@ constexpr int DEFAULT_TOR_CONTROL_PORT = 9051;
|
||||
extern const std::string DEFAULT_TOR_CONTROL;
|
||||
static const bool DEFAULT_LISTEN_ONION = true;
|
||||
|
||||
/** Tor control reply code. Ref: https://spec.torproject.org/control-spec/replies.html */
|
||||
constexpr int TOR_REPLY_OK{250};
|
||||
constexpr int TOR_REPLY_UNRECOGNIZED{510};
|
||||
|
||||
void StartTorControl(CService onion_service_target);
|
||||
void InterruptTorControl();
|
||||
void StopTorControl();
|
||||
|
||||
Reference in New Issue
Block a user