Skip to content

Commit 58cf47a

Browse files
committed
Merge #221: test default PassField impl handles output parameters
6db6696 test In|Out parameter (Novo) 29cf2ad test default PassField impl handles output parameters (Novo) Pull request description: This PR adds two test cases to ensure that output parameter results from a server call are correctly captured and included in the response. The new tests also serve as practical examples of how to work with output parameters and `in|out` parameters in the codebase. ### Testing Automated coverage is not yet available, see #198. As a temporary verification method: - Comment out [these lines](https://github.com/bitcoin-core/libmultiprocess/blob/47d79db8a5528097b408e18f7b0bae11a6702d26/include/mp/proxy-types.h#L308-L310) and run make check. The new test should fail, confirming it is effective. - If you then also comment out the newly added tests and rerun make check, it should pass, demonstrating that the lines above were previously uncovered. ACKs for top commit: ryanofsky: Code review ACK 6db6696. Thanks, both changes look good! Tree-SHA512: c6d0604d41a840e27bb3b039b08516ffca160f4215f46983a462102eaa9a4c09c8b8375715ad7fdc1c1da9bb94387cb2d716a3b9bca8e7a118c81de0ceb00eb7
2 parents db03a66 + 6db6696 commit 58cf47a

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

test/mp/test/foo.capnp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ $Proxy.includeTypes("mp/test/foo-types.h");
1313

1414
interface FooInterface $Proxy.wrap("mp::test::FooImplementation") {
1515
add @0 (a :Int32, b :Int32) -> (result :Int32);
16+
addOut @19 (a :Int32, b :Int32) -> (ret :Int32);
17+
addInOut @20 (x :Int32, sum :Int32) -> (sum :Int32);
1618
mapSize @1 (map :List(Pair(Text, Text))) -> (result :Int32);
1719
pass @2 (arg :FooStruct) -> (result :FooStruct);
1820
raise @3 (arg :FooStruct) -> (error :FooStruct $Proxy.exception("mp::test::FooStruct"));

test/mp/test/foo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class FooImplementation
6262
{
6363
public:
6464
int add(int a, int b) { return a + b; }
65+
void addOut(int a, int b, int& out) { out = a + b; }
66+
void addInOut(int x, int& sum) { sum += x; }
6567
int mapSize(const std::map<std::string, std::string>& map) { return map.size(); }
6668
FooStruct pass(FooStruct foo) { return foo; }
6769
void raise(FooStruct foo) { throw foo; }

test/mp/test/test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ KJ_TEST("Call FooInterface methods")
120120
ProxyClient<messages::FooInterface>* foo = setup.client.get();
121121

122122
KJ_EXPECT(foo->add(1, 2) == 3);
123+
int ret;
124+
foo->addOut(3, 4, ret);
125+
KJ_EXPECT(ret == 7);
126+
foo->addInOut(3, ret);
127+
KJ_EXPECT(ret == 10);
123128

124129
FooStruct in;
125130
in.name = "name";

0 commit comments

Comments
 (0)