Coverage Report

Created: 2026-04-29 19:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/tmp/bitcoin/src/ipc/test/ipc_tests.cpp
Line
Count
Source
1
// Copyright (c) 2023-present 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 <ipc/process.h>
6
#include <ipc/test/ipc_test.h>
7
8
#include <test/util/common.h>
9
#include <test/util/setup_common.h>
10
#include <boost/test/unit_test.hpp>
11
12
BOOST_FIXTURE_TEST_SUITE(ipc_tests, BasicTestingSetup)
13
BOOST_AUTO_TEST_CASE(ipc_tests)
14
1
{
15
1
    IpcPipeTest();
16
1
    IpcSocketPairTest();
17
1
    IpcSocketTest(m_args.GetDataDirNet());
18
1
}
19
20
// Test address parsing.
21
BOOST_AUTO_TEST_CASE(parse_address_test)
22
1
{
23
1
    std::unique_ptr<ipc::Process> process{ipc::MakeProcess()};
24
1
    fs::path datadir{"/var/empty/notexist"};
25
3
    auto check_notexist{[](const std::system_error& e) { return e.code() == std::errc::no_such_file_or_directory; }};
26
5
    auto check_address{[&](std::string address, std::string expect_address, std::string expect_error) {
27
5
        if (expect_error.empty()) {
28
3
            BOOST_CHECK_EXCEPTION(process->connect(datadir, "test_bitcoin", address), std::system_error, check_notexist);
29
3
        } else {
30
2
            BOOST_CHECK_EXCEPTION(process->connect(datadir, "test_bitcoin", address), std::invalid_argument, HasReason(expect_error));
31
2
        }
32
5
        BOOST_CHECK_EQUAL(address, expect_address);
33
5
    }};
34
1
    check_address("unix", "unix:/var/empty/notexist/test_bitcoin.sock", "");
35
1
    check_address("unix:", "unix:/var/empty/notexist/test_bitcoin.sock", "");
36
1
    check_address("unix:path.sock", "unix:/var/empty/notexist/path.sock", "");
37
1
    check_address("unix:0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.sock",
38
1
                  "unix:/var/empty/notexist/0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.sock",
39
1
                  "Unix address path \"/var/empty/notexist/0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.sock\" exceeded maximum socket path length");
40
1
    check_address("invalid", "invalid", "Unrecognized address 'invalid'");
41
1
}
42
43
BOOST_AUTO_TEST_SUITE_END()