LCOV - code coverage report
Current view: top level - src/util - chaintype.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 95.5 % 22 21
Test Date: 2024-09-01 05:20:30 Functions: 100.0 % 2 2
Branches: 76.9 % 26 20

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2023 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 <util/chaintype.h>
       6                 :             : 
       7                 :             : #include <cassert>
       8                 :             : #include <optional>
       9                 :             : #include <string>
      10                 :             : 
      11                 :     2403474 : std::string ChainTypeToString(ChainType chain)
      12                 :             : {
      13   [ -  +  +  +  :     2403474 :     switch (chain) {
                   +  + ]
      14                 :             :     case ChainType::MAIN:
      15         [ +  - ]:     2401591 :         return "main";
      16                 :             :     case ChainType::TESTNET:
      17         [ +  - ]:          10 :         return "test";
      18                 :             :     case ChainType::TESTNET4:
      19         [ +  - ]:           6 :         return "testnet4";
      20                 :             :     case ChainType::SIGNET:
      21         [ +  - ]:          14 :         return "signet";
      22                 :             :     case ChainType::REGTEST:
      23         [ +  - ]:        1853 :         return "regtest";
      24                 :             :     }
      25                 :           0 :     assert(false);
      26                 :     2403474 : }
      27                 :             : 
      28                 :          43 : std::optional<ChainType> ChainTypeFromString(std::string_view chain)
      29                 :             : {
      30         [ +  + ]:          43 :     if (chain == "main") {
      31                 :           2 :         return ChainType::MAIN;
      32         [ +  + ]:          41 :     } else if (chain == "test") {
      33                 :           1 :         return ChainType::TESTNET;
      34         [ +  + ]:          40 :     } else if (chain == "testnet4") {
      35                 :           1 :         return ChainType::TESTNET4;
      36         [ +  + ]:          39 :     } else if (chain == "signet") {
      37                 :           2 :         return ChainType::SIGNET;
      38         [ +  + ]:          37 :     } else if (chain == "regtest") {
      39                 :           1 :         return ChainType::REGTEST;
      40                 :             :     } else {
      41                 :          36 :         return std::nullopt;
      42                 :             :     }
      43                 :          43 : }
        

Generated by: LCOV version 2.0-1