LCOV - code coverage report
Current view: top level - src/test/fuzz - decode_tx.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 3 18 16.7 %
Date: 2023-10-05 12:38:51 Functions: 3 4 75.0 %
Branches: 2 32 6.2 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2019-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 <core_io.h>
       6                 :            : #include <primitives/transaction.h>
       7                 :            : #include <test/fuzz/fuzz.h>
       8                 :            : #include <util/strencodings.h>
       9                 :            : 
      10                 :            : #include <cassert>
      11                 :            : #include <cstdint>
      12                 :            : #include <string>
      13                 :            : #include <vector>
      14                 :            : 
      15         [ -  + ]:          4 : FUZZ_TARGET(decode_tx)
      16                 :            : {
      17                 :          0 :     const std::string tx_hex = HexStr(buffer);
      18         [ #  # ]:          0 :     CMutableTransaction mtx;
      19         [ #  # ]:          0 :     const bool result_none = DecodeHexTx(mtx, tx_hex, false, false);
      20         [ #  # ]:          0 :     const bool result_try_witness = DecodeHexTx(mtx, tx_hex, false, true);
      21         [ #  # ]:          0 :     const bool result_try_witness_and_maybe_no_witness = DecodeHexTx(mtx, tx_hex, true, true);
      22         [ #  # ]:          0 :     CMutableTransaction no_witness_mtx;
      23         [ #  # ]:          0 :     const bool result_try_no_witness = DecodeHexTx(no_witness_mtx, tx_hex, true, false);
      24         [ #  # ]:          0 :     assert(!result_none);
      25   [ +  -  #  # ]:          2 :     if (result_try_witness_and_maybe_no_witness) {
      26   [ #  #  #  # ]:          0 :         assert(result_try_no_witness || result_try_witness);
      27                 :          0 :     }
      28         [ #  # ]:          0 :     if (result_try_no_witness) {
      29   [ #  #  #  # ]:          0 :         assert(!no_witness_mtx.HasWitness());
      30         [ #  # ]:          0 :         assert(result_try_witness_and_maybe_no_witness);
      31                 :          0 :     }
      32                 :          0 : }

Generated by: LCOV version 1.14