Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
61d748d6
Commit
61d748d6
authored
Nov 09, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for pipelining over two-party RPC.
parent
28073325
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
rpc-twoparty-test.c++
c++/src/capnp/rpc-twoparty-test.c++
+53
-0
No files found.
c++/src/capnp/rpc-twoparty-test.c++
View file @
61d748d6
...
...
@@ -134,6 +134,59 @@ TEST(TwoPartyNetwork, Basic) {
EXPECT_TRUE
(
barFailed
);
}
TEST
(
TwoPartyNetwork
,
Pipelining
)
{
int
callCount
=
0
;
int
reverseCallCount
=
0
;
// Calls back from server to client.
// We'll communicate over this two-way pipe (actually, a socketpair).
auto
pipe
=
kj
::
newTwoWayPipe
();
// Start up server in another thread.
auto
quitter
=
kj
::
newPromiseAndFulfiller
<
void
>
();
kj
::
Thread
thread
([
&
]()
{
runServer
(
kj
::
mv
(
quitter
.
promise
),
kj
::
mv
(
pipe
.
ends
[
1
]),
callCount
);
});
KJ_DEFER
(
quitter
.
fulfiller
->
fulfill
());
// Stop the server loop before destroying the thread.
// Set up the client-side objects.
kj
::
UnixEventLoop
loop
;
TwoPartyVatNetwork
network
(
loop
,
*
pipe
.
ends
[
0
],
rpc
::
twoparty
::
Side
::
CLIENT
);
auto
rpcClient
=
makeRpcClient
(
network
,
loop
);
// Request the particular capability from the server.
auto
client
=
getPersistentCap
(
rpcClient
,
rpc
::
twoparty
::
Side
::
SERVER
,
test
::
TestSturdyRefObjectId
::
Tag
::
TEST_PIPELINE
).
castAs
<
test
::
TestPipeline
>
();
// Use the capability.
auto
request
=
client
.
getCapRequest
();
request
.
setN
(
234
);
request
.
setInCap
(
test
::
TestInterface
::
Client
(
kj
::
heap
<
TestInterfaceImpl
>
(
reverseCallCount
),
loop
));
auto
promise
=
request
.
send
();
auto
pipelineRequest
=
promise
.
getOutBox
().
getCap
().
fooRequest
();
pipelineRequest
.
setI
(
321
);
auto
pipelinePromise
=
pipelineRequest
.
send
();
auto
pipelineRequest2
=
promise
.
getOutBox
().
getCap
().
castAs
<
test
::
TestExtends
>
().
graultRequest
();
auto
pipelinePromise2
=
pipelineRequest2
.
send
();
promise
=
nullptr
;
// Just to be annoying, drop the original promise.
EXPECT_EQ
(
0
,
callCount
);
EXPECT_EQ
(
0
,
reverseCallCount
);
auto
response
=
loop
.
wait
(
kj
::
mv
(
pipelinePromise
));
EXPECT_EQ
(
"bar"
,
response
.
getX
());
auto
response2
=
loop
.
wait
(
kj
::
mv
(
pipelinePromise2
));
checkTestMessage
(
response2
);
EXPECT_EQ
(
3
,
callCount
);
EXPECT_EQ
(
1
,
reverseCallCount
);
}
}
// namespace
}
// namespace _
}
// namespace capnp
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment