aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2021-08-11 22:40:13 -0400
committerluigi1111 <luigi1111w@gmail.com>2021-08-11 22:40:13 -0400
commit82149bfe441e56d5f9d72a13ffa25ce1df6d8391 (patch)
treedca9428448629cea75f298051bbd5e93581ace98 /tests
parentMerge pull request #7816 (diff)
parentunit_tests: fix broken tests (diff)
downloadmonero-82149bfe441e56d5f9d72a13ffa25ce1df6d8391.tar.xz
Merge pull request #7818
9c8e3e8 unit_tests: fix broken tests (anon)
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/epee_boosted_tcp_server.cpp6
-rw-r--r--tests/unit_tests/node_server.cpp10
2 files changed, 8 insertions, 8 deletions
diff --git a/tests/unit_tests/epee_boosted_tcp_server.cpp b/tests/unit_tests/epee_boosted_tcp_server.cpp
index d10b2bb33..992122dd2 100644
--- a/tests/unit_tests/epee_boosted_tcp_server.cpp
+++ b/tests/unit_tests/epee_boosted_tcp_server.cpp
@@ -111,8 +111,7 @@ TEST(boosted_tcp_server, worker_threads_are_exception_resistant)
{
boost::unique_lock<boost::mutex> lock(mtx);
- ASSERT_NE(boost::cv_status::timeout, cond.wait_for(lock, boost::chrono::seconds(5)));
- ASSERT_EQ(4, counter);
+ ASSERT_TRUE(cond.wait_for(lock, boost::chrono::seconds(5), [&counter]{ return counter == 4; }));
}
// 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);
- ASSERT_NE(boost::cv_status::timeout, cond.wait_for(lock, boost::chrono::seconds(5)));
- ASSERT_EQ(4, counter);
+ ASSERT_TRUE(cond.wait_for(lock, boost::chrono::seconds(5), [&counter]{ return counter == 4; }));
}
srv.send_stop_signal();
diff --git a/tests/unit_tests/node_server.cpp b/tests/unit_tests/node_server.cpp
index 2c80acda5..cab600b3d 100644
--- a/tests/unit_tests/node_server.cpp
+++ b/tests/unit_tests/node_server.cpp
@@ -795,9 +795,11 @@ TEST(cryptonote_protocol_handler, race_condition)
workers_t workers;
} check;
check.work = std::make_shared<work_t>(check.io_context);
- check.workers.emplace_back([&check]{
- check.io_context.run();
- });
+ while (check.workers.size() < 2) {
+ check.workers.emplace_back([&check]{
+ check.io_context.run();
+ });
+ }
while (daemon.main.conn.size() < 1) {
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, {}, {}));
@@ -856,7 +858,7 @@ TEST(cryptonote_protocol_handler, race_condition)
}
}
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, {}, {}));
create_conn_pair(daemon.main.conn.back(), daemon.alt.conn.back());
conduct_handshake(daemon.alt.net_node, daemon.alt.conn.back());