MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / IpcSocketPairTest

Function IpcSocketPairTest

src/ipc/test/ipc_test.cpp:120–137  ·  view source on GitHub ↗

Test ipc::Protocol connect() and serve() methods connecting over a socketpair.

Source from the content-addressed store, hash-verified

118
119//! Test ipc::Protocol connect() and serve() methods connecting over a socketpair.
120void IpcSocketPairTest()
121{
122 int fds[2];
123 BOOST_CHECK_EQUAL(socketpair(AF_UNIX, SOCK_STREAM, 0, fds), 0);
124 std::unique_ptr<interfaces::Init> init{std::make_unique<TestInit>()};
125 std::unique_ptr<ipc::Protocol> protocol{ipc::capnp::MakeCapnpProtocol()};
126 std::promise<void> promise;
127 std::thread thread([&]() {
128 protocol->serve(fds[0], "test-serve", *init, [&] { promise.set_value(); });
129 });
130 promise.get_future().wait();
131 std::unique_ptr<interfaces::Init> remote_init{protocol->connect(fds[1], "test-connect")};
132 std::unique_ptr<interfaces::Echo> remote_echo{remote_init->makeEcho()};
133 BOOST_CHECK_EQUAL(remote_echo->echo("echo test"), "echo test");
134 remote_echo.reset();
135 remote_init.reset();
136 thread.join();
137}
138
139//! Test ipc::Process bind() and connect() methods connecting over a unix socket.
140void IpcSocketTest(const fs::path& datadir)

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 8

MakeCapnpProtocolFunction · 0.85
serveMethod · 0.80
echoMethod · 0.80
joinMethod · 0.80
waitMethod · 0.45
connectMethod · 0.45
makeEchoMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected