summaryrefslogtreecommitdiff
path: root/modules/remote/tests
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-10-22 18:33:00 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-10-22 18:33:00 +0200
commit05a7fa9a2815b63b5b6f7eea107807e33aa62137 (patch)
treef810107a00dd88d8135be2db0fb4dafd736c9ad5 /modules/remote/tests
parent98cf3372f2ed4e61ccb0acc522549aaa3d18fd59 (diff)
Trying to get the reference working
Diffstat (limited to 'modules/remote/tests')
-rw-r--r--modules/remote/tests/remote_loopback.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/modules/remote/tests/remote_loopback.cpp b/modules/remote/tests/remote_loopback.cpp
index d6f1e73..e1f3898 100644
--- a/modules/remote/tests/remote_loopback.cpp
+++ b/modules/remote/tests/remote_loopback.cpp
@@ -31,20 +31,38 @@ SAW_TEST("Remote Loopback RPC"){
auto eo_i64_srv = rmt.template data_listen<sch::Int64, encode::Native>(*addr);
SAW_EXPECT(eo_i64_srv.is_value(), std::string{"Couldn't listen: "} + std::string{eo_i64_srv.get_error().get_category()});
auto& i64_srv = eo_i64_srv.get_value();
+
+ auto foo_func = [](data<sch::UInt32, encode::Native> input) -> error_or<data<sch::Int64, encode::Native>> {
+ data<sch::Int64, encode::Native> rv;
+ rv.set(input.get() * 2);
+ return rv;
+ };
+
+ auto iface = interface_factory<sch::TestInterface, encode::Native>::create(std::move(foo_func));
- auto eo_rpc_srv = rmt.template rpc_listen<sch::TestInterface, encode::Native>(*addr, {
- [](data<sch::UInt32, encode::Native> input) -> error_or<data<sch::Int64, encode::Native>> {
- data<sch::Int64, encode::Native> rv;
- rv.set(input.get() * 2);
- return rv;
- }
- });
+ auto eo_rpc_srv = rmt.template rpc_listen<sch::TestInterface, encode::Native>(*addr, std::move(iface));
SAW_EXPECT(eo_rpc_srv.is_value(), std::string{"Couldn't listen: "} + std::string{eo_rpc_srv.get_error().get_category()});
auto& rpc_srv = eo_rpc_srv.get_value();
id<sch::UInt32> id32{0u};
id<sch::Int64> id64{0u};
+ data<sch::UInt32, encode::Native> inp{21};
+
+ {
+ auto eo_send = u32_srv->send(inp, id32);
+ SAW_EXPECT(eo_send.is_value(), "Failed send.");
+ }
+ auto eo_called = rpc_srv->template call<"foo">(id32);
+ SAW_EXPECT(eo_called.is_value(), "Failed call.");
+ auto& called = eo_called.get_value();
+
+ {
+ auto eo_recv = i64_srv->receive(called);
+ SAW_EXPECT(eo_recv.is_value(), "Failed receive.");
+ auto& recv = eo_recv.get_value();
+ SAW_EXPECT((recv.get() == 42), (std::string{"Wrong value received: "} + std::to_string(recv.get())));
+ }
}
SAW_TEST("Remote Loopback Data"){