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

             Branch data     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 <chainparams.h>
       6                 :             : #include <key_io.h>
       7                 :             : #include <test/fuzz/fuzz.h>
       8                 :             : #include <util/chaintype.h>
       9                 :             : 
      10                 :             : #include <cassert>
      11                 :             : #include <cstdint>
      12                 :             : #include <string>
      13                 :             : #include <vector>
      14                 :             : 
      15                 :           0 : void initialize_key_io()
      16                 :             : {
      17   [ #  #  #  #  :           0 :     static ECC_Context ecc_context{};
                   #  # ]
      18                 :           0 :     SelectParams(ChainType::MAIN);
      19                 :           0 : }
      20                 :             : 
      21         [ #  # ]:           0 : FUZZ_TARGET(key_io, .init = initialize_key_io)
      22                 :             : {
      23         [ #  # ]:           0 :     const std::string random_string(buffer.begin(), buffer.end());
      24                 :             : 
      25         [ #  # ]:           0 :     const CKey key = DecodeSecret(random_string);
      26         [ #  # ]:           0 :     if (key.IsValid()) {
      27   [ #  #  #  #  :           0 :         assert(key == DecodeSecret(EncodeSecret(key)));
                   #  # ]
      28                 :             :     }
      29                 :             : 
      30         [ #  # ]:           0 :     const CExtKey ext_key = DecodeExtKey(random_string);
      31         [ #  # ]:           0 :     if (ext_key.key.size() == 32) {
      32   [ #  #  #  #  :           0 :         assert(ext_key == DecodeExtKey(EncodeExtKey(ext_key)));
                   #  # ]
      33                 :             :     }
      34                 :             : 
      35         [ #  # ]:           0 :     const CExtPubKey ext_pub_key = DecodeExtPubKey(random_string);
      36         [ #  # ]:           0 :     if (ext_pub_key.pubkey.size() == CPubKey::COMPRESSED_SIZE) {
      37   [ #  #  #  #  :           0 :         assert(ext_pub_key == DecodeExtPubKey(EncodeExtPubKey(ext_pub_key)));
                   #  # ]
      38                 :             :     }
      39                 :           0 : }
        

Generated by: LCOV version 2.0-1