* Move nano::establish_tcp into nano::test namespace * Move system.hpp declarations into namespace nano::test * Move telemetry test code to namespace nano::test * Move testutil declarations into namespace nano::test
25 lines
887 B
C++
25 lines
887 B
C++
#include <nano/node/node.hpp>
|
|
#include <nano/test_common/network.hpp>
|
|
#include <nano/test_common/system.hpp>
|
|
#include <nano/test_common/testutil.hpp>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <chrono>
|
|
#include <future>
|
|
|
|
using namespace std::chrono_literals;
|
|
|
|
std::shared_ptr<nano::transport::channel_tcp> nano::test::establish_tcp (nano::test::system & system, nano::node & node, nano::endpoint const & endpoint)
|
|
{
|
|
debug_assert (node.network.endpoint () != endpoint && "Establishing TCP to self is not allowed");
|
|
|
|
std::shared_ptr<nano::transport::channel_tcp> result;
|
|
debug_assert (!node.flags.disable_tcp_realtime);
|
|
node.network.tcp_channels.start_tcp (endpoint);
|
|
auto error = system.poll_until_true (2s, [&result, &node, &endpoint] {
|
|
result = node.network.tcp_channels.find_channel (nano::transport::map_endpoint_to_tcp (endpoint));
|
|
return result != nullptr;
|
|
});
|
|
return result;
|
|
}
|