* Move `test::get_available_port` to `test::system` class * Use ephemeral ports in tests * Fix database directories for core tests * Fix rpc tests * Use `SO_REUSEADDR` * Fix `ipv6_bind_send_ipv4` * Use 0 to bind to any port by default * Fix `network` tests * Fix `socket` tests * Fix `ipc` tests * Fix remaining tests * Raise the file limit soft-cap when running tests in parallel. * Importing gtest-parallel as a submodule. --------- Co-authored-by: Colin LeMahieu <clemahieu@gmail.com>
33 lines
1.2 KiB
C++
33 lines
1.2 KiB
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;
|
|
}
|
|
|
|
std::shared_ptr<nano::node> nano::test::add_outer_node (nano::test::system & system_a, nano::node_flags flags_a)
|
|
{
|
|
auto outer_node = std::make_shared<nano::node> (system_a.io_ctx, system_a.get_available_port (), nano::unique_path (), system_a.logging, system_a.work, flags_a);
|
|
outer_node->start ();
|
|
system_a.nodes.push_back (outer_node);
|
|
return outer_node;
|
|
}
|