LCOV - code coverage report
Current view: top level - src/test/fuzz - base_encode_decode.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 0.0 % 29 0
Test Date: 2024-08-28 04:44:32 Functions: 0.0 % 2 0
Branches: 0.0 % 80 0

             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 <test/fuzz/fuzz.h>
       6                 :             : 
       7                 :             : #include <base58.h>
       8                 :             : #include <psbt.h>
       9                 :             : #include <util/strencodings.h>
      10                 :             : #include <util/string.h>
      11                 :             : 
      12                 :             : #include <cassert>
      13                 :             : #include <cstdint>
      14                 :             : #include <string>
      15                 :             : #include <vector>
      16                 :             : 
      17                 :             : using util::TrimString;
      18                 :             : using util::TrimStringView;
      19                 :             : 
      20         [ #  # ]:           0 : FUZZ_TARGET(base_encode_decode)
      21                 :             : {
      22         [ #  # ]:           0 :     const std::string random_encoded_string(buffer.begin(), buffer.end());
      23                 :             : 
      24                 :           0 :     std::vector<unsigned char> decoded;
      25   [ #  #  #  # ]:           0 :     if (DecodeBase58(random_encoded_string, decoded, 100)) {
      26         [ #  # ]:           0 :         const std::string encoded_string = EncodeBase58(decoded);
      27   [ #  #  #  # ]:           0 :         assert(encoded_string == TrimStringView(encoded_string));
      28   [ #  #  #  #  :           0 :         assert(ToLower(encoded_string) == ToLower(TrimString(random_encoded_string)));
             #  #  #  # ]
      29                 :           0 :     }
      30                 :             : 
      31   [ #  #  #  # ]:           0 :     if (DecodeBase58Check(random_encoded_string, decoded, 100)) {
      32         [ #  # ]:           0 :         const std::string encoded_string = EncodeBase58Check(decoded);
      33   [ #  #  #  # ]:           0 :         assert(encoded_string == TrimString(encoded_string));
      34   [ #  #  #  #  :           0 :         assert(ToLower(encoded_string) == ToLower(TrimString(random_encoded_string)));
             #  #  #  # ]
      35                 :           0 :     }
      36                 :             : 
      37         [ #  # ]:           0 :     auto result = DecodeBase32(random_encoded_string);
      38         [ #  # ]:           0 :     if (result) {
      39         [ #  # ]:           0 :         const std::string encoded_string = EncodeBase32(*result);
      40   [ #  #  #  # ]:           0 :         assert(encoded_string == TrimStringView(encoded_string));
      41   [ #  #  #  #  :           0 :         assert(ToLower(encoded_string) == ToLower(TrimString(random_encoded_string)));
             #  #  #  # ]
      42                 :           0 :     }
      43                 :             : 
      44         [ #  # ]:           0 :     result = DecodeBase64(random_encoded_string);
      45         [ #  # ]:           0 :     if (result) {
      46         [ #  # ]:           0 :         const std::string encoded_string = EncodeBase64(*result);
      47   [ #  #  #  # ]:           0 :         assert(encoded_string == TrimString(encoded_string));
      48   [ #  #  #  #  :           0 :         assert(ToLower(encoded_string) == ToLower(TrimString(random_encoded_string)));
             #  #  #  # ]
      49                 :           0 :     }
      50                 :             : 
      51                 :           0 :     PartiallySignedTransaction psbt;
      52         [ #  # ]:           0 :     std::string error;
      53         [ #  # ]:           0 :     (void)DecodeBase64PSBT(psbt, random_encoded_string, error);
      54                 :           0 : }
        

Generated by: LCOV version 2.0-1