LCOV - code coverage report
Current view: top level - src/test/fuzz - script_interpreter.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 20 20 100.0 %
Date: 2023-10-05 15:40:34 Functions: 3 3 100.0 %
Branches: 21 36 58.3 %

           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         [ -  + ]:        727 : FUZZ_TARGET(script_interpreter)
      19                 :            : {
      20                 :        381 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      21                 :            :     {
      22                 :        381 :         const CScript script_code = ConsumeScript(fuzzed_data_provider);
      23                 :        381 :         const std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
      24         [ +  + ]:        381 :         if (mtx) {
      25   [ +  -  +  -  :        360 :             const CTransaction tx_to{*mtx};
                   +  - ]
      26         [ +  - ]:        187 :             const unsigned int in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
      27         [ +  + ]:        187 :             if (in < tx_to.vin.size()) {
      28   [ +  -  +  -  :        174 :                 (void)SignatureHash(script_code, tx_to, in, fuzzed_data_provider.ConsumeIntegral<int>(), ConsumeMoney(fuzzed_data_provider), fuzzed_data_provider.PickValueInArray({SigVersion::BASE, SigVersion::WITNESS_V0}), nullptr);
                   +  - ]
      29                 :        174 :                 const std::optional<CMutableTransaction> mtx_precomputed = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
      30         [ +  + ]:        174 :                 if (mtx_precomputed) {
      31   [ +  -  +  - ]:         75 :                     const CTransaction tx_precomputed{*mtx_precomputed};
      32         [ -  + ]:         75 :                     const PrecomputedTransactionData precomputed_transaction_data{tx_precomputed};
      33   [ +  -  +  -  :         75 :                     (void)SignatureHash(script_code, tx_to, in, fuzzed_data_provider.ConsumeIntegral<int>(), ConsumeMoney(fuzzed_data_provider), fuzzed_data_provider.PickValueInArray({SigVersion::BASE, SigVersion::WITNESS_V0}), &precomputed_transaction_data);
                   +  - ]
      34                 :         75 :                 }
      35                 :        174 :             }
      36                 :        187 :         }
      37                 :        381 :     }
      38                 :            :     {
      39         [ +  - ]:        381 :         (void)CastToBool(ConsumeRandomLengthByteVector(fuzzed_data_provider));
      40                 :            :     }
      41                 :        381 : }

Generated by: LCOV version 1.14