diff options
author | luigi1111 <luigi1111w@gmail.com> | 2021-04-06 12:25:00 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2021-04-06 12:25:00 -0500 |
commit | 4834bd8aa005511b28a62ec565506e811b870abc (patch) | |
tree | 114d765f1d809f3257c42efb73a4d47229b4b12d /tests/unit_tests | |
parent | Merge pull request #7639 (diff) | |
parent | Tests: Fix test node_server.bind_same_p2p_port from randomly crashing (diff) | |
download | monero-4834bd8aa005511b28a62ec565506e811b870abc.tar.xz |
Merge pull request #7646
176cea0 Tests: Fix test node_server.bind_same_p2p_port from randomly crashing (mj-xmr)
Diffstat (limited to 'tests/unit_tests')
-rw-r--r-- | tests/unit_tests/node_server.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/unit_tests/node_server.cpp b/tests/unit_tests/node_server.cpp index fc7886485..8d5c784eb 100644 --- a/tests/unit_tests/node_server.cpp +++ b/tests/unit_tests/node_server.cpp @@ -293,6 +293,18 @@ TEST(node_server, bind_same_p2p_port) boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::parse_command_line(1, argv, desc_options), vm); + /* + Reason for choosing '127.0.0.2' as the IP: + + A TCP local socket address that has been bound is unavailable for some time after closing, unless the SO_REUSEADDR flag has been set. + That's why connections with automatically assigned source port 48080/58080 from previous test blocks the next to bind acceptor + so solution is to either set reuse_addr option for each socket in all tests + or use ip different from localhost for acceptors in order to not interfere with automatically assigned source endpoints + + Relevant part about REUSEADDR from man: + https://www.man7.org/linux/man-pages/man7/ip.7.html + */ + vm.find(nodetool::arg_p2p_bind_ip.name)->second = boost::program_options::variable_value(std::string("127.0.0.2"), false); vm.find(nodetool::arg_p2p_bind_port.name)->second = boost::program_options::variable_value(std::string(port), false); boost::program_options::notify(vm); |