Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c707e75

Browse filesBrowse files
committed
Reproduce #187
1 parent 666fb0a commit c707e75
Copy full SHA for c707e75

File tree

1 file changed

+21
-1
lines changed
Filter options

1 file changed

+21
-1
lines changed

‎tests/rpc/this_server_test.cc

Copy file name to clipboardExpand all lines: tests/rpc/this_server_test.cc
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "gtest/gtest.h"
22

3+
#include <future>
4+
35
#include "rpc/client.h"
46
#include "rpc/server.h"
57
#include "rpc/this_server.h"
@@ -24,7 +26,7 @@ class this_server_test : public testing::Test {
2426
rpc::client c2;
2527
};
2628

27-
TEST_F(this_server_test, stop) {
29+
TEST_F(this_server_test, stop_async) {
2830
s.bind("stop_server", []() { rpc::this_server().stop(); });
2931
s.async_run();
3032
c1.call("stop_server");
@@ -35,3 +37,21 @@ TEST_F(this_server_test, stop) {
3537
EXPECT_EQ(c2.get_connection_state(),
3638
client::connection_state::disconnected);
3739
}
40+
41+
TEST_F(this_server_test, stop_sync) {
42+
s.bind("stop_server", []() { rpc::this_server().stop(); });
43+
44+
auto handle = std::async(std::launch::async, [this]() {
45+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
46+
c1.call("stop_server");
47+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
48+
});
49+
50+
s.run();
51+
handle.get();
52+
53+
EXPECT_EQ(c1.get_connection_state(),
54+
client::connection_state::disconnected);
55+
EXPECT_EQ(c2.get_connection_state(),
56+
client::connection_state::disconnected);
57+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.