LCOV - code coverage report
Current view: top level - src/test/fuzz - script_format.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 15 15
Test Date: 2024-12-04 04:00:22 Functions: 100.0 % 3 3
Branches: 66.7 % 12 8

             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         [ +  - ]:        1398 : FUZZ_TARGET(script_format, .init = initialize_script_format)
      22                 :             : {
      23                 :         986 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      24                 :         986 :     const CScript script{ConsumeScript(fuzzed_data_provider)};
      25   [ +  +  +  + ]:         986 :     if (script.size() > MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR) {
      26                 :          11 :         return;
      27                 :             :     }
      28                 :             : 
      29         [ +  - ]:         975 :     (void)FormatScript(script);
      30         [ +  - ]:         975 :     (void)ScriptToAsmStr(script, /*fAttemptSighashDecode=*/fuzzed_data_provider.ConsumeBool());
      31                 :             : 
      32                 :         975 :     UniValue o1(UniValue::VOBJ);
      33                 :         975 :     auto include_hex = fuzzed_data_provider.ConsumeBool();
      34                 :         975 :     auto include_address = fuzzed_data_provider.ConsumeBool();
      35         [ +  - ]:         975 :     ScriptToUniv(script, /*out=*/o1, include_hex, include_address);
      36                 :         986 : }
        

Generated by: LCOV version 2.0-1