add timer for test

This commit is contained in:
Jeff Becker 2018-11-02 13:56:48 -04:00
parent 05a6e66aa0
commit 3e84915d47
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

View File

@ -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));