From 3e84915d477eb4ece6f953b1c889723996126fb3 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 2 Nov 2018 13:56:48 -0400 Subject: [PATCH] add timer for test --- test/jsonrpc_unittest.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/jsonrpc_unittest.cpp b/test/jsonrpc_unittest.cpp index 052d3f465..17089e41b 100644 --- a/test/jsonrpc_unittest.cpp +++ b/test/jsonrpc_unittest.cpp @@ -27,6 +27,22 @@ struct AbyssTestBase : public ::testing::Test llarp_crypto_init(&crypto); } + static void + CancelIt(void* u, uint64_t orig, uint64_t left) + { + if(left) + return; + static_cast< AbyssTestBase* >(u)->Cancel(); + } + + /// cancel test because of timeout + void + Cancel() + { + Stop(); + ASSERT_TRUE(false); + } + void Start() { @@ -44,6 +60,7 @@ struct AbyssTestBase : public ::testing::Test if(server->ServeAsync(loop, logic, a)) { client->RunAsync(loop, a.ToString()); + llarp_logic_call_later(logic, {1000, this, &CancelIt}); return; } std::this_thread::sleep_for(std::chrono::seconds(1));