LCOV - code coverage report
Current view: top level - src/test/fuzz - script_interpreter.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 28 28
Test Date: 2025-01-22 04:09:46 Functions: 100.0 % 2 2
Branches: 65.0 % 20 13

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2020 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 <primitives/transaction.h>
       6                 :             : #include <script/interpreter.h>
       7                 :             : #include <test/fuzz/FuzzedDataProvider.h>
       8                 :             : #include <test/fuzz/fuzz.h>
       9                 :             : #include <test/fuzz/util.h>
      10                 :             : 
      11                 :             : #include <cstdint>
      12                 :             : #include <optional>
      13                 :             : #include <string>
      14                 :             : #include <vector>
      15                 :             : 
      16                 :             : bool CastToBool(const std::vector<unsigned char>& vch);
      17                 :             : 
      18         [ +  - ]:        1068 : FUZZ_TARGET(script_interpreter)
      19                 :             : {
      20                 :         654 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      21                 :         654 :     {
      22                 :         654 :         const CScript script_code = ConsumeScript(fuzzed_data_provider);
      23                 :         654 :         const std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);
      24         [ +  + ]:         654 :         if (mtx) {
      25         [ +  - ]:         459 :             const CTransaction tx_to{*mtx};
      26                 :         459 :             const unsigned int in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
      27         [ +  + ]:         459 :             if (in < tx_to.vin.size()) {
      28                 :         431 :                 auto n_hash_type = fuzzed_data_provider.ConsumeIntegral<int>();
      29                 :         431 :                 auto amount = ConsumeMoney(fuzzed_data_provider);
      30                 :         431 :                 auto sigversion = fuzzed_data_provider.PickValueInArray({SigVersion::BASE, SigVersion::WITNESS_V0});
      31         [ +  - ]:         431 :                 (void)SignatureHash(script_code, tx_to, in, n_hash_type, amount, sigversion, nullptr);
      32                 :         431 :                 const std::optional<CMutableTransaction> mtx_precomputed = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);
      33         [ +  + ]:         431 :                 if (mtx_precomputed) {
      34         [ +  - ]:         201 :                     const CTransaction tx_precomputed{*mtx_precomputed};
      35         [ +  - ]:         201 :                     const PrecomputedTransactionData precomputed_transaction_data{tx_precomputed};
      36                 :         201 :                     n_hash_type = fuzzed_data_provider.ConsumeIntegral<int>();
      37                 :         201 :                     amount = ConsumeMoney(fuzzed_data_provider);
      38                 :         201 :                     sigversion = fuzzed_data_provider.PickValueInArray({SigVersion::BASE, SigVersion::WITNESS_V0});
      39         [ +  - ]:         201 :                     (void)SignatureHash(script_code, tx_to, in, n_hash_type, amount, sigversion, &precomputed_transaction_data);
      40                 :         402 :                 }
      41                 :         431 :             }
      42                 :         459 :         }
      43                 :         654 :     }
      44                 :         654 :     {
      45         [ +  - ]:         654 :         (void)CastToBool(ConsumeRandomLengthByteVector(fuzzed_data_provider));
      46                 :             :     }
      47                 :         654 : }
        

Generated by: LCOV version 2.0-1