LCOV - code coverage report
Current view: top level - src/test/fuzz - script_ops.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 2 48 4.2 %
Date: 2023-09-26 12:08:55 Functions: 2 10 20.0 %

          Line data    Source code
       1             : // Copyright (c) 2020-2021 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 <script/script.h>
       6             : #include <test/fuzz/FuzzedDataProvider.h>
       7             : #include <test/fuzz/fuzz.h>
       8             : #include <test/fuzz/util.h>
       9             : 
      10             : #include <cstdint>
      11             : #include <string>
      12             : #include <vector>
      13             : 
      14           4 : FUZZ_TARGET(script_ops)
      15             : {
      16           0 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      17           0 :     CScript script_mut = ConsumeScript(fuzzed_data_provider);
      18           0 :     LIMITED_WHILE(fuzzed_data_provider.remaining_bytes() > 0, 1000000) {
      19           0 :         CallOneOf(
      20             :             fuzzed_data_provider,
      21           0 :             [&] {
      22           0 :                 CScript s = ConsumeScript(fuzzed_data_provider);
      23           0 :                 script_mut = std::move(s);
      24           0 :             },
      25           2 :             [&] {
      26           0 :                 const CScript& s = ConsumeScript(fuzzed_data_provider);
      27           0 :                 script_mut = s;
      28           0 :             },
      29           0 :             [&] {
      30           0 :                 script_mut << fuzzed_data_provider.ConsumeIntegral<int64_t>();
      31           0 :             },
      32           0 :             [&] {
      33           0 :                 script_mut << ConsumeOpcodeType(fuzzed_data_provider);
      34           0 :             },
      35           0 :             [&] {
      36           0 :                 script_mut << ConsumeScriptNum(fuzzed_data_provider);
      37           0 :             },
      38           0 :             [&] {
      39           0 :                 script_mut << ConsumeRandomLengthByteVector(fuzzed_data_provider);
      40           0 :             },
      41           0 :             [&] {
      42           0 :                 script_mut.clear();
      43           0 :             });
      44           0 :     }
      45           0 :     const CScript& script = script_mut;
      46           0 :     (void)script.GetSigOpCount(false);
      47           0 :     (void)script.GetSigOpCount(true);
      48           0 :     (void)script.GetSigOpCount(script);
      49           0 :     (void)script.HasValidOps();
      50           0 :     (void)script.IsPayToScriptHash();
      51           0 :     (void)script.IsPayToWitnessScriptHash();
      52           0 :     (void)script.IsPushOnly();
      53           0 :     (void)script.IsUnspendable();
      54             :     {
      55           0 :         CScript::const_iterator pc = script.begin();
      56             :         opcodetype opcode;
      57           0 :         (void)script.GetOp(pc, opcode);
      58           0 :         std::vector<uint8_t> data;
      59           0 :         (void)script.GetOp(pc, opcode, data);
      60           0 :         (void)script.IsPushOnly(pc);
      61           0 :     }
      62             :     {
      63             :         int version;
      64           0 :         std::vector<uint8_t> program;
      65           0 :         (void)script.IsWitnessProgram(version, program);
      66           0 :     }
      67           0 : }

Generated by: LCOV version 1.14