LCOV - code coverage report
Current view: top level - src/test/fuzz - torcontrol.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 45 45
Test Date: 2026-04-29 06:25:28 Functions: 100.0 % 9 9
Branches: 61.1 % 18 11

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2020-present The Bitcoin Core developers
       2                 :             : // Distributed under the MIT software license, see the accompanying
       3                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :             : 
       5                 :             : #include <test/fuzz/FuzzedDataProvider.h>
       6                 :             : #include <test/fuzz/fuzz.h>
       7                 :             : #include <test/fuzz/util.h>
       8                 :             : #include <test/util/setup_common.h>
       9                 :             : #include <torcontrol.h>
      10                 :             : 
      11                 :             : #include <cstdint>
      12                 :             : #include <string>
      13                 :             : #include <vector>
      14                 :             : 
      15                 :           1 : void initialize_torcontrol()
      16                 :             : {
      17   [ +  -  +  -  :           1 :     static const auto testing_setup = MakeNoLogFileContext<>();
                   +  - ]
      18                 :           1 : }
      19                 :             : 
      20         [ +  - ]:         828 : FUZZ_TARGET(torcontrol, .init = initialize_torcontrol)
      21                 :             : {
      22                 :         370 :     FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
      23                 :             : 
      24                 :         370 :     TorController tor_controller;
      25         [ +  - ]:         370 :     CThreadInterrupt interrupt;
      26         [ +  - ]:         370 :     TorControlConnection conn{interrupt};
      27                 :             : 
      28   [ +  +  +  + ]:      151183 :     LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
      29                 :      150813 :         TorControlReply tor_control_reply;
      30                 :      150813 :         CallOneOf(
      31                 :             :             fuzzed_data_provider,
      32                 :       31202 :             [&] {
      33                 :       31202 :                 tor_control_reply.code = TOR_REPLY_OK;
      34                 :       31202 :             },
      35                 :       21358 :             [&] {
      36                 :       21358 :                 tor_control_reply.code = TOR_REPLY_UNRECOGNIZED;
      37                 :       21358 :             },
      38                 :       22982 :             [&] {
      39                 :       22982 :                 tor_control_reply.code = TOR_REPLY_SYNTAX_ERROR;
      40                 :       22982 :             },
      41                 :       75271 :             [&] {
      42                 :       75271 :                 tor_control_reply.code = fuzzed_data_provider.ConsumeIntegral<int>();
      43                 :       75271 :             });
      44                 :      150813 :         tor_control_reply.lines = ConsumeRandomLengthStringVector(fuzzed_data_provider);
      45                 :             : 
      46         [ +  - ]:      150813 :         CallOneOf(
      47                 :             :             fuzzed_data_provider,
      48                 :       30390 :             [&] {
      49                 :       30390 :                 tor_controller.add_onion_cb(conn, tor_control_reply, /*pow_was_enabled=*/true);
      50                 :       30390 :             },
      51                 :       73707 :             [&] {
      52                 :       73707 :                 tor_controller.add_onion_cb(conn, tor_control_reply, /*pow_was_enabled=*/false);
      53                 :       73707 :             },
      54                 :       10979 :             [&] {
      55                 :       10979 :                 tor_controller.auth_cb(conn, tor_control_reply);
      56                 :       10979 :             },
      57                 :       13276 :             [&] {
      58                 :       13276 :                 tor_controller.authchallenge_cb(conn, tor_control_reply);
      59                 :       13276 :             },
      60                 :       22179 :             [&] {
      61                 :       22179 :                 tor_controller.protocolinfo_cb(conn, tor_control_reply);
      62                 :       22179 :             },
      63                 :         282 :             [&] {
      64                 :         282 :                 tor_controller.get_socks_cb(conn, tor_control_reply);
      65                 :         282 :             });
      66                 :      150813 :     }
      67                 :         370 : }
        

Generated by: LCOV version 2.0-1