LCOV - code coverage report
Current view: top level - src/test/fuzz - parse_univalue.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 4 66 6.1 %
Date: 2023-11-10 23:46:46 Functions: 1 8 12.5 %
Branches: 3 150 2.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2009-2022 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 <chainparams.h>
       6                 :            : #include <rpc/client.h>
       7                 :            : #include <rpc/util.h>
       8                 :            : #include <test/fuzz/fuzz.h>
       9                 :            : #include <util/chaintype.h>
      10                 :            : 
      11                 :            : #include <limits>
      12                 :            : #include <string>
      13                 :            : 
      14                 :          0 : void initialize_parse_univalue()
      15                 :            : {
      16                 :          0 :     SelectParams(ChainType::REGTEST);
      17         [ +  - ]:          2 : }
      18         [ +  - ]:          2 : 
      19         [ +  - ]:          4 : FUZZ_TARGET(parse_univalue, .init = initialize_parse_univalue)
      20                 :            : {
      21         [ #  # ]:          0 :     const std::string random_string(buffer.begin(), buffer.end());
      22                 :          0 :     bool valid = true;
      23         [ #  # ]:          0 :     const UniValue univalue = [&] {
      24                 :          0 :         UniValue uv;
      25 [ #  # ][ #  # ]:          0 :         if (!uv.read(random_string)) valid = false;
      26 [ #  # ][ #  # ]:          0 :         return valid ? uv : UniValue{};
                 [ #  # ]
      27                 :          2 :     }();
      28         [ #  # ]:          0 :     if (!valid) {
      29                 :          0 :         return;
      30                 :            :     }
      31                 :            :     try {
      32         [ #  # ]:          0 :         (void)ParseHashO(univalue, "A");
      33 [ #  # ][ #  # ]:          0 :     } catch (const UniValue&) {
      34         [ #  # ]:          0 :     } catch (const std::runtime_error&) {
      35         [ #  # ]:          0 :     }
      36                 :            :     try {
      37         [ #  # ]:          0 :         (void)ParseHashO(univalue, random_string);
      38 [ #  # ][ #  # ]:          0 :     } catch (const UniValue&) {
      39         [ #  # ]:          0 :     } catch (const std::runtime_error&) {
      40         [ #  # ]:          0 :     }
      41                 :            :     try {
      42         [ #  # ]:          0 :         (void)ParseHashV(univalue, "A");
      43 [ #  # ][ #  # ]:          0 :     } catch (const UniValue&) {
      44         [ #  # ]:          0 :     } catch (const std::runtime_error&) {
      45         [ #  # ]:          0 :     }
      46                 :            :     try {
      47         [ #  # ]:          0 :         (void)ParseHashV(univalue, random_string);
      48 [ #  # ][ #  # ]:          0 :     } catch (const UniValue&) {
      49         [ #  # ]:          0 :     } catch (const std::runtime_error&) {
      50         [ #  # ]:          0 :     }
      51                 :            :     try {
      52         [ #  # ]:          0 :         (void)ParseHexO(univalue, "A");
      53         [ #  # ]:          0 :     } catch (const UniValue&) {
      54         [ #  # ]:          0 :     }
      55                 :            :     try {
      56         [ #  # ]:          0 :         (void)ParseHexO(univalue, random_string);
      57         [ #  # ]:          0 :     } catch (const UniValue&) {
      58         [ #  # ]:          0 :     }
      59                 :            :     try {
      60         [ #  # ]:          0 :         (void)ParseHexV(univalue, "A");
      61 [ #  # ][ #  # ]:          0 :     } catch (const UniValue&) {
      62         [ #  # ]:          0 :     } catch (const std::runtime_error&) {
      63         [ #  # ]:          0 :     }
      64                 :            :     try {
      65         [ #  # ]:          0 :         (void)ParseHexV(univalue, random_string);
      66 [ #  # ][ #  # ]:          0 :     } catch (const UniValue&) {
      67         [ #  # ]:          0 :     } catch (const std::runtime_error&) {
      68         [ #  # ]:          0 :     }
      69                 :            :     try {
      70 [ #  # ][ #  # ]:          0 :         if (univalue.isNull() || univalue.isStr()) (void)ParseSighashString(univalue);
         [ #  # ][ #  # ]
                 [ #  # ]
      71         [ #  # ]:          0 :     } catch (const UniValue&) {
      72         [ #  # ]:          0 :     }
      73                 :            :     try {
      74         [ #  # ]:          0 :         (void)AmountFromValue(univalue);
      75 [ #  # ][ #  # ]:          0 :     } catch (const UniValue&) {
      76         [ #  # ]:          0 :     } catch (const std::runtime_error&) {
      77         [ #  # ]:          0 :     }
      78                 :            :     try {
      79                 :          0 :         FlatSigningProvider provider;
      80         [ #  # ]:          0 :         (void)EvalDescriptorStringOrObject(univalue, provider);
      81 [ #  # ][ #  # ]:          0 :     } catch (const UniValue&) {
      82         [ #  # ]:          0 :     } catch (const std::runtime_error&) {
      83         [ #  # ]:          0 :     }
      84                 :            :     try {
      85         [ #  # ]:          0 :         (void)ParseConfirmTarget(univalue, std::numeric_limits<unsigned int>::max());
      86 [ #  # ][ #  # ]:          0 :     } catch (const UniValue&) {
      87         [ #  # ]:          0 :     } catch (const std::runtime_error&) {
      88         [ #  # ]:          0 :     }
      89                 :            :     try {
      90         [ #  # ]:          0 :         (void)ParseDescriptorRange(univalue);
      91 [ #  # ][ #  # ]:          0 :     } catch (const UniValue&) {
      92         [ #  # ]:          0 :     } catch (const std::runtime_error&) {
      93         [ #  # ]:          0 :     }
      94         [ #  # ]:          0 : }

Generated by: LCOV version 1.14