mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
test: Setup networking globally
This commit is contained in:
parent
31ce305d46
commit
fd4c6a10f2
@ -21,7 +21,7 @@
|
||||
int64_t GetStartupTime();
|
||||
|
||||
void SetupEnvironment();
|
||||
bool SetupNetworking();
|
||||
[[nodiscard]] bool SetupNetworking();
|
||||
#ifndef WIN32
|
||||
std::string ShellEscape(const std::string& arg);
|
||||
#endif
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include <txdb.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/check.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
@ -88,6 +89,15 @@ std::ostream& operator<<(std::ostream& os, const uint256& num)
|
||||
return os;
|
||||
}
|
||||
|
||||
struct NetworkSetup
|
||||
{
|
||||
NetworkSetup()
|
||||
{
|
||||
Assert(SetupNetworking());
|
||||
}
|
||||
};
|
||||
static NetworkSetup g_networksetup_instance;
|
||||
|
||||
BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vector<const char*>& extra_args)
|
||||
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()},
|
||||
m_args{}
|
||||
@ -130,7 +140,6 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vecto
|
||||
LogInstance().StartLogging();
|
||||
m_node.kernel = std::make_unique<kernel::Context>();
|
||||
SetupEnvironment();
|
||||
SetupNetworking();
|
||||
|
||||
ValidationCacheSizes validation_cache_sizes{};
|
||||
ApplyArgsManOptions(*m_node.args, validation_cache_sizes);
|
||||
|
@ -1218,6 +1218,9 @@ BOOST_AUTO_TEST_CASE(test_LockDirectory)
|
||||
// has released the lock as we would expect by probing it.
|
||||
int processstatus;
|
||||
BOOST_CHECK_EQUAL(write(fd[1], &LockCommand, 1), 1);
|
||||
// The following line invokes the ~CNetCleanup dtor without
|
||||
// a paired SetupNetworking call. This is acceptable as long as
|
||||
// ~CNetCleanup is a no-op for non-Windows platforms.
|
||||
BOOST_CHECK_EQUAL(write(fd[1], &ExitCommand, 1), 1);
|
||||
BOOST_CHECK_EQUAL(waitpid(pid, &processstatus, 0), pid);
|
||||
BOOST_CHECK_EQUAL(processstatus, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user