LCOV - code coverage report
Current view: top level - src/util - chaintype.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 7 19 36.8 %
Date: 2023-09-26 12:08:55 Functions: 1 2 50.0 %

          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       79258 : std::string ChainTypeToString(ChainType chain)
      12             : {
      13       79258 :     switch (chain) {
      14             :     case ChainType::MAIN:
      15       79254 :         return "main";
      16             :     case ChainType::TESTNET:
      17           1 :         return "test";
      18             :     case ChainType::SIGNET:
      19           1 :         return "signet";
      20             :     case ChainType::REGTEST:
      21           2 :         return "regtest";
      22             :     }
      23           0 :     assert(false);
      24       79258 : }
      25             : 
      26           0 : std::optional<ChainType> ChainTypeFromString(std::string_view chain)
      27             : {
      28           0 :     if (chain == "main") {
      29           0 :         return ChainType::MAIN;
      30           0 :     } else if (chain == "test") {
      31           0 :         return ChainType::TESTNET;
      32           0 :     } else if (chain == "signet") {
      33           0 :         return ChainType::SIGNET;
      34           0 :     } else if (chain == "regtest") {
      35           0 :         return ChainType::REGTEST;
      36             :     } else {
      37           0 :         return std::nullopt;
      38             :     }
      39           0 : }

Generated by: LCOV version 1.14