Files
bitcoin/src/test/fuzz/torcontrol.cpp
MarcoFalke fab8eeed82 fuzz: clang-format LIMITED_WHILE
This is a whitespace-only clang-format change.

To verify it, one can run:

```sh
(git show | git apply --reverse ) && ( git diff -U0 | ./contrib/devtools/clang-format-diff.py -p1 -i -v ) && git diff HEAD
```

A few minor, non-macro formatting adjustments were made in touched files:

* `src/wallet/test/fuzz/crypter.cpp`: Removed a redundant double semicolon
* `src/test/fuzz/txorphan.cpp`: Corrected indentation on an `else if` block.
* `src/test/fuzz/mini_miner.cpp`: Removed an unnecessary empty line.
2026-07-14 13:48:33 +02:00

68 lines
2.1 KiB
C++

// Copyright (c) 2020-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <test/util/setup_common.h>
#include <torcontrol.h>
#include <cstdint>
#include <string>
#include <vector>
void initialize_torcontrol()
{
static const auto testing_setup = MakeNoLogFileContext<>();
}
FUZZ_TARGET(torcontrol, .init = initialize_torcontrol)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
TorController tor_controller;
CThreadInterrupt interrupt;
TorControlConnection conn{interrupt};
LIMITED_WHILE (fuzzed_data_provider.ConsumeBool(), 10000) {
TorControlReply tor_control_reply;
CallOneOf(
fuzzed_data_provider,
[&] {
tor_control_reply.code = TOR_REPLY_OK;
},
[&] {
tor_control_reply.code = TOR_REPLY_UNRECOGNIZED;
},
[&] {
tor_control_reply.code = TOR_REPLY_SYNTAX_ERROR;
},
[&] {
tor_control_reply.code = fuzzed_data_provider.ConsumeIntegral<int>();
});
tor_control_reply.lines = ConsumeRandomLengthStringVector(fuzzed_data_provider);
CallOneOf(
fuzzed_data_provider,
[&] {
tor_controller.add_onion_cb(conn, tor_control_reply, /*pow_was_enabled=*/true);
},
[&] {
tor_controller.add_onion_cb(conn, tor_control_reply, /*pow_was_enabled=*/false);
},
[&] {
tor_controller.auth_cb(conn, tor_control_reply);
},
[&] {
tor_controller.authchallenge_cb(conn, tor_control_reply);
},
[&] {
tor_controller.protocolinfo_cb(conn, tor_control_reply);
},
[&] {
tor_controller.get_socks_cb(conn, tor_control_reply);
});
}
}