Coverage Report

Created: 2025-06-10 13:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/bitcoin/src/util/chaintype.cpp
Line
Count
Source
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
std::string ChainTypeToString(ChainType chain)
12
18.9M
{
13
18.9M
    switch (chain) {
  Branch (13:13): [True: 0, False: 18.9M]
14
18.9M
    case ChainType::MAIN:
  Branch (14:5): [True: 18.9M, False: 66.5k]
15
18.9M
        return "main";
16
11.0k
    case ChainType::TESTNET:
  Branch (16:5): [True: 11.0k, False: 18.9M]
17
11.0k
        return "test";
18
11.0k
    case ChainType::TESTNET4:
  Branch (18:5): [True: 11.0k, False: 18.9M]
19
11.0k
        return "testnet4";
20
11.0k
    case ChainType::SIGNET:
  Branch (20:5): [True: 11.0k, False: 18.9M]
21
11.0k
        return "signet";
22
33.2k
    case ChainType::REGTEST:
  Branch (22:5): [True: 33.2k, False: 18.9M]
23
33.2k
        return "regtest";
24
18.9M
    }
25
18.9M
    assert(false);
  Branch (25:5): [Folded - Ignored]
26
0
}
27
28
std::optional<ChainType> ChainTypeFromString(std::string_view chain)
29
0
{
30
0
    if (chain == "main") {
  Branch (30:9): [True: 0, False: 0]
31
0
        return ChainType::MAIN;
32
0
    } else if (chain == "test") {
  Branch (32:16): [True: 0, False: 0]
33
0
        return ChainType::TESTNET;
34
0
    } else if (chain == "testnet4") {
  Branch (34:16): [True: 0, False: 0]
35
0
        return ChainType::TESTNET4;
36
0
    } else if (chain == "signet") {
  Branch (36:16): [True: 0, False: 0]
37
0
        return ChainType::SIGNET;
38
0
    } else if (chain == "regtest") {
  Branch (38:16): [True: 0, False: 0]
39
0
        return ChainType::REGTEST;
40
0
    } else {
41
0
        return std::nullopt;
42
0
    }
43
0
}