From 5af4a2e6136bc554745a8693813961252edfaf14 Mon Sep 17 00:00:00 2001 From: Wesley Shillingford Date: Wed, 29 Apr 2020 21:49:38 +0100 Subject: [PATCH] Fix network.tcp_no_connect_excluded_peers test failure on MacOS (#2750) --- nano/core_test/network.cpp | 3 +++ nano/node/network.cpp | 6 ++++++ nano/node/network.hpp | 1 + 3 files changed, 10 insertions(+) diff --git a/nano/core_test/network.cpp b/nano/core_test/network.cpp index 4842b4277..de6615733 100644 --- a/nano/core_test/network.cpp +++ b/nano/core_test/network.cpp @@ -1121,6 +1121,9 @@ TEST (network, tcp_no_connect_excluded_peers) node0->network.excluded_peers.remove (endpoint1_tcp); ASSERT_FALSE (node0->network.excluded_peers.check (endpoint1_tcp)); + // Wait until there is a syn_cookie + ASSERT_TIMELY (5s, node1->network.syn_cookies.cookies_size () != 0); + // Manually cleanup previous attempt node1->network.cleanup (std::chrono::steady_clock::now ()); node1->network.syn_cookies.purge (std::chrono::steady_clock::now ()); diff --git a/nano/node/network.cpp b/nano/node/network.cpp index 8eb1fc790..4094d4c53 100644 --- a/nano/node/network.cpp +++ b/nano/node/network.cpp @@ -1007,6 +1007,12 @@ void nano::syn_cookies::purge (std::chrono::steady_clock::time_point const & cut } } +size_t nano::syn_cookies::cookies_size () +{ + nano::lock_guard lock (syn_cookie_mutex); + return cookies.size (); +} + std::unique_ptr nano::collect_container_info (network & network, const std::string & name) { auto composite = std::make_unique (name); diff --git a/nano/node/network.hpp b/nano/node/network.hpp index 8b3036549..9d5945bdc 100644 --- a/nano/node/network.hpp +++ b/nano/node/network.hpp @@ -99,6 +99,7 @@ public: // Also removes the syn cookie from the store if valid bool validate (nano::endpoint const &, nano::account const &, nano::signature const &); std::unique_ptr collect_container_info (std::string const &); + size_t cookies_size (); private: class syn_cookie_info final