6 #include <mp/proxy-types.h>
7 #include <test/ipc_test.capnp.h>
8 #include <test/ipc_test.capnp.proxy.h>
12 #include <kj/common.h>
13 #include <kj/memory.h>
16 #include <boost/test/unit_test.hpp>
29 std::promise<std::unique_ptr<mp::ProxyClient<gen::FooInterface>>> foo_promise;
30 std::function<void()> disconnect_client;
31 std::thread thread([&]() {
32 mp::EventLoop loop(
"IpcTest", [](
bool raise,
const std::string& log) {
LogPrintf(
"LOG%i: %s\n",
raise, log); });
33 auto pipe = loop.m_io_context.provider->newTwoWayPipe();
35 auto connection_client = std::make_unique<mp::Connection>(loop, kj::mv(pipe.ends[0]));
36 auto foo_client = std::make_unique<mp::ProxyClient<gen::FooInterface>>(
37 connection_client->m_rpc_system.bootstrap(mp::ServerVatId().vat_id).castAs<gen::FooInterface>(),
38 connection_client.get(),
false);
39 foo_promise.set_value(std::move(foo_client));
40 disconnect_client = [&] { loop.sync([&] { connection_client.reset(); }); };
42 auto connection_server = std::make_unique<mp::Connection>(loop, kj::mv(pipe.ends[1]), [&](mp::Connection& connection) {
43 auto foo_server = kj::heap<mp::ProxyServer<gen::FooInterface>>(std::make_shared<FooImplementation>(), connection);
44 return capnp::Capability::Client(kj::mv(foo_server));
46 connection_server->onDisconnect([&] { connection_server.reset(); });
49 std::unique_ptr<mp::ProxyClient<gen::FooInterface>> foo{foo_promise.get_future().get()};
55 COutPoint txout2{foo->passOutPoint(txout1)};
60 uni1.pushKV(
"s",
"two");
61 UniValue uni2{foo->passUniValue(uni1)};
An outpoint - a combination of a transaction hash and an index n into its vout.
static transaction_identifier FromUint256(const uint256 &id)
void IpcTest()
Unit test that tests execution of IPC calls without actually creating a separate process.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)