Skip to content

Commit

Permalink
tests: improve rpc timeout test
Browse files Browse the repository at this point in the history
Wait for timed outed reply before existing the application.
  • Loading branch information
gleb-cloudius authored and avikivity committed Sep 7, 2015
1 parent c4490c6 commit 9a9f3d6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/rpc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main(int ac, char** av) {
auto test4 = myrpc.register_handler(4, [](){ print("test4 throw!\n"); throw std::runtime_error("exception!"); });
auto test5 = myrpc.register_handler(5, [](){ print("test5 no wait\n"); return rpc::no_wait; });
auto test6 = myrpc.register_handler(6, [](const rpc::client_info& info, int x){ print("test6 client %s, %d\n", inet_ntoa(info.addr.as_posix_sockaddr_in().sin_addr), x); });
auto test8 = myrpc.register_handler(8, [](){ print("test8 sleep for 5 sec\n"); return sleep(5s); });
auto test8 = myrpc.register_handler(8, [](){ print("test8 sleep for 5 sec\n"); return sleep(2s); });

if (config.count("server")) {
std::cout << "client" << std::endl;
Expand Down Expand Up @@ -135,8 +135,10 @@ int main(int ac, char** av) {
test7(*client, 5, 6).then([] (long r) { print("test7 got %ld\n", r); });
}
f.finally([] {
client->stop().then([] {
engine().exit(0);
sleep(1s).then([] {
client->stop().then([] {
engine().exit(0);
});
});
});
} else {
Expand Down

0 comments on commit 9a9f3d6

Please sign in to comment.