aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2023-11-20 15:49:55 -0500
committerRyan Ofsky <ryan@ofsky.org>2023-11-28 12:35:50 -0500
commit0cc74fce72e0c79849109ee5d7afe707991b3512 (patch)
tree234486b6cef3518731c9c283cfac3ec3afd128fd /src/test
parent4aaee239211a5287fbc361c0eb158b105ae8c8db (diff)
multiprocess: Add type conversion code for serializable types
Allow any C++ object that has Serialize and Unserialize methods and can be serialized to a bitcoin CDataStream to be converted to a capnproto Data field and passed as arguments or return values to capnproto methods using the Data type. Extend IPC unit test to cover this and verify the serialization happens correctly.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ipc_test.capnp2
-rw-r--r--src/test/ipc_test.cpp6
-rw-r--r--src/test/ipc_test.h1
3 files changed, 8 insertions, 1 deletions
diff --git a/src/test/ipc_test.capnp b/src/test/ipc_test.capnp
index f8473a4dec..7b970e2aff 100644
--- a/src/test/ipc_test.capnp
+++ b/src/test/ipc_test.capnp
@@ -9,7 +9,9 @@ $Cxx.namespace("gen");
using Proxy = import "/mp/proxy.capnp";
$Proxy.include("test/ipc_test.h");
+$Proxy.includeTypes("ipc/capnp/common-types.h");
interface FooInterface $Proxy.wrap("FooImplementation") {
add @0 (a :Int32, b :Int32) -> (result :Int32);
+ passOutPoint @1 (arg :Data) -> (result :Data);
}
diff --git a/src/test/ipc_test.cpp b/src/test/ipc_test.cpp
index b84255f68b..f835859705 100644
--- a/src/test/ipc_test.cpp
+++ b/src/test/ipc_test.cpp
@@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <mp/proxy-types.h>
#include <logging.h>
+#include <mp/proxy-types.h>
#include <test/ipc_test.capnp.h>
#include <test/ipc_test.capnp.proxy.h>
#include <test/ipc_test.h>
@@ -51,6 +51,10 @@ void IpcTest()
// Test: make sure arguments were sent and return value is received
BOOST_CHECK_EQUAL(foo->add(1, 2), 3);
+ COutPoint txout1{Txid::FromUint256(uint256{100}), 200};
+ COutPoint txout2{foo->passOutPoint(txout1)};
+ BOOST_CHECK(txout1 == txout2);
+
// Test cleanup: disconnect pipe and join thread
disconnect_client();
thread.join();
diff --git a/src/test/ipc_test.h b/src/test/ipc_test.h
index 61c85b5a47..f100ae8c5d 100644
--- a/src/test/ipc_test.h
+++ b/src/test/ipc_test.h
@@ -11,6 +11,7 @@ class FooImplementation
{
public:
int add(int a, int b) { return a + b; }
+ COutPoint passOutPoint(COutPoint o) { return o; }
};
void IpcTest();