unit_tests: fix broken tests
boosted_tcp_server: check condition before sleep too cryptonote_protocol_handler: each instance of BlockchainLMDB requires separate thread due to private thread local fields
This commit is contained in:
parent
8b63bb3c75
commit
1510b1e550
|
@ -111,8 +111,7 @@ TEST(boosted_tcp_server, worker_threads_are_exception_resistant)
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> lock(mtx);
|
boost::unique_lock<boost::mutex> lock(mtx);
|
||||||
ASSERT_NE(boost::cv_status::timeout, cond.wait_for(lock, boost::chrono::seconds(5)));
|
ASSERT_TRUE(cond.wait_for(lock, boost::chrono::seconds(5), [&counter]{ return counter == 4; }));
|
||||||
ASSERT_EQ(4, counter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if threads are alive
|
// Check if threads are alive
|
||||||
|
@ -125,8 +124,7 @@ TEST(boosted_tcp_server, worker_threads_are_exception_resistant)
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> lock(mtx);
|
boost::unique_lock<boost::mutex> lock(mtx);
|
||||||
ASSERT_NE(boost::cv_status::timeout, cond.wait_for(lock, boost::chrono::seconds(5)));
|
ASSERT_TRUE(cond.wait_for(lock, boost::chrono::seconds(5), [&counter]{ return counter == 4; }));
|
||||||
ASSERT_EQ(4, counter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
srv.send_stop_signal();
|
srv.send_stop_signal();
|
||||||
|
|
|
@ -803,9 +803,11 @@ TEST(cryptonote_protocol_handler, race_condition)
|
||||||
workers_t workers;
|
workers_t workers;
|
||||||
} check;
|
} check;
|
||||||
check.work = std::make_shared<work_t>(check.io_context);
|
check.work = std::make_shared<work_t>(check.io_context);
|
||||||
check.workers.emplace_back([&check]{
|
while (check.workers.size() < 2) {
|
||||||
check.io_context.run();
|
check.workers.emplace_back([&check]{
|
||||||
});
|
check.io_context.run();
|
||||||
|
});
|
||||||
|
}
|
||||||
while (daemon.main.conn.size() < 1) {
|
while (daemon.main.conn.size() < 1) {
|
||||||
daemon.main.conn.emplace_back(new connection_t(check.io_context, daemon.main.shared_state, {}, {}));
|
daemon.main.conn.emplace_back(new connection_t(check.io_context, daemon.main.shared_state, {}, {}));
|
||||||
daemon.alt.conn.emplace_back(new connection_t(io_context, daemon.alt.shared_state, {}, {}));
|
daemon.alt.conn.emplace_back(new connection_t(io_context, daemon.alt.shared_state, {}, {}));
|
||||||
|
@ -864,7 +866,7 @@ TEST(cryptonote_protocol_handler, race_condition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (daemon.main.conn.size() < 2) {
|
while (daemon.main.conn.size() < 2) {
|
||||||
daemon.main.conn.emplace_back(new connection_t(io_context, daemon.main.shared_state, {}, {}));
|
daemon.main.conn.emplace_back(new connection_t(check.io_context, daemon.main.shared_state, {}, {}));
|
||||||
daemon.alt.conn.emplace_back(new connection_t(io_context, daemon.alt.shared_state, {}, {}));
|
daemon.alt.conn.emplace_back(new connection_t(io_context, daemon.alt.shared_state, {}, {}));
|
||||||
create_conn_pair(daemon.main.conn.back(), daemon.alt.conn.back());
|
create_conn_pair(daemon.main.conn.back(), daemon.alt.conn.back());
|
||||||
conduct_handshake(daemon.alt.net_node, daemon.alt.conn.back());
|
conduct_handshake(daemon.alt.net_node, daemon.alt.conn.back());
|
||||||
|
|
Loading…
Reference in New Issue