Skip to content
Snippets Groups Projects
Commit fbb4608d authored by François-Simon Fauteux-Chapleau's avatar François-Simon Fauteux-Chapleau
Browse files

tests: don't sleep for 5 seconds in IceTest::setUp

We do need to wait for the DHT's public address to become available
after bootstrapping it before we can start the tests, but 5 seconds is
much longer than typically necessary.

Change-Id: I1c1094eafbe9c81767439009ba751b69cae24d08
parent 2569341f
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@
#include <asio/io_context.hpp>
#include "opendht/dhtrunner.h"
#include "opendht/sockaddr.h"
#include "opendht/thread_pool.h"
#include "test_runner.h"
#include "upnp/upnp_context.h"
......@@ -82,9 +83,22 @@ IceTest::setUp()
dht_ = std::make_shared<dht::DhtRunner>();
dht::DhtRunner::Config config {};
dht::DhtRunner::Context context {};
std::mutex mtx;
std::unique_lock lk(mtx);
std::condition_variable cv;
context.publicAddressChangedCb = [&](std::vector<dht::SockAddr> addr) {
if (addr.size() != 0)
cv.notify_all();
};
dht_->run(0, config, std::move(context));
dht_->bootstrap("bootstrap.jami.net:4222");
std::this_thread::sleep_for(std::chrono::seconds(5));
// Wait for the DHT's public address to be available, otherwise the assertion that
// `addr4.size() != 0` at the beginning of several of the tests will fail.
cv.wait_for(lk, std::chrono::seconds(5), [&] {
return dht_->getPublicAddress().size() != 0;
});
}
if (!turnV4_) {
turnV4_ = std::make_unique<dhtnet::IpAddr>("turn.jami.net", AF_INET);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment