LCOV - code coverage report
Current view: top level - src/test/fuzz - script_format.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 14 14 100.0 %
Date: 2023-10-05 15:40:34 Functions: 5 5 100.0 %
Branches: 13 24 54.2 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2019-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 <consensus/consensus.h>
       7                 :            : #include <core_io.h>
       8                 :            : #include <policy/policy.h>
       9                 :            : #include <script/script.h>
      10                 :            : #include <test/fuzz/FuzzedDataProvider.h>
      11                 :            : #include <test/fuzz/fuzz.h>
      12                 :            : #include <test/fuzz/util.h>
      13                 :            : #include <univalue.h>
      14                 :            : #include <util/chaintype.h>
      15                 :            : 
      16                 :          1 : void initialize_script_format()
      17                 :            : {
      18                 :          1 :     SelectParams(ChainType::REGTEST);
      19                 :          1 : }
      20                 :            : 
      21   [ +  -  -  + ]:        816 : FUZZ_TARGET(script_format, .init = initialize_script_format)
      22                 :            : {
      23                 :        470 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      24                 :        470 :     const CScript script{ConsumeScript(fuzzed_data_provider)};
      25   [ +  -  +  + ]:        470 :     if (script.size() > MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR) {
      26                 :         12 :         return;
      27                 :            :     }
      28                 :            : 
      29         [ +  - ]:        458 :     (void)FormatScript(script);
      30   [ +  -  +  - ]:        458 :     (void)ScriptToAsmStr(script, /*fAttemptSighashDecode=*/fuzzed_data_provider.ConsumeBool());
      31                 :            : 
      32         [ +  - ]:        458 :     UniValue o1(UniValue::VOBJ);
      33   [ +  -  +  -  :        458 :     ScriptToUniv(script, /*out=*/o1, /*include_hex=*/fuzzed_data_provider.ConsumeBool(), /*include_address=*/fuzzed_data_provider.ConsumeBool());
                   +  - ]
      34         [ -  + ]:        470 : }

Generated by: LCOV version 1.14