Passing nano::networks enum in to working_path rather than statically constructing it.

This commit is contained in:
clemahieu 2021-08-08 16:02:05 +01:00
commit c2f19a3837
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
3 changed files with 8 additions and 9 deletions

View file

@ -2,6 +2,7 @@
#include <nano/node/common.hpp> #include <nano/node/common.hpp>
#include <nano/node/logging.hpp> #include <nano/node/logging.hpp>
#include <nano/secure/utility.hpp>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
@ -9,7 +10,6 @@ namespace nano
{ {
void cleanup_dev_directories_on_exit (); void cleanup_dev_directories_on_exit ();
void force_nano_dev_network (); void force_nano_dev_network ();
boost::filesystem::path unique_path ();
} }
GTEST_API_ int main (int argc, char ** argv) GTEST_API_ int main (int argc, char ** argv)

View file

@ -6,11 +6,10 @@
static std::vector<boost::filesystem::path> all_unique_paths; static std::vector<boost::filesystem::path> all_unique_paths;
boost::filesystem::path nano::working_path () boost::filesystem::path nano::working_path (nano::networks network)
{ {
static nano::network_constants network_constants;
auto result (nano::app_path ()); auto result (nano::app_path ());
switch (network_constants.network ()) switch (network)
{ {
case nano::networks::invalid: case nano::networks::invalid:
release_assert (false); release_assert (false);
@ -31,9 +30,9 @@ boost::filesystem::path nano::working_path ()
return result; return result;
} }
boost::filesystem::path nano::unique_path () boost::filesystem::path nano::unique_path (nano::networks network)
{ {
auto result (working_path () / boost::filesystem::unique_path ()); auto result (working_path (network) / boost::filesystem::unique_path ());
all_unique_paths.push_back (result); all_unique_paths.push_back (result);
return result; return result;
} }

View file

@ -1,16 +1,16 @@
#pragma once #pragma once
#include <crypto/cryptopp/osrng.h> #include <nano/lib/config.hpp>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
namespace nano namespace nano
{ {
// OS-specific way of finding a path to a home directory. // OS-specific way of finding a path to a home directory.
boost::filesystem::path working_path (); boost::filesystem::path working_path (nano::networks network = nano::network_constants::active_network);
// Get a unique path within the home directory, used for testing. // Get a unique path within the home directory, used for testing.
// Any directories created at this location will be removed when a test finishes. // Any directories created at this location will be removed when a test finishes.
boost::filesystem::path unique_path (); boost::filesystem::path unique_path (nano::networks network = nano::network_constants::active_network);
// Remove all unique tmp directories created by the process // Remove all unique tmp directories created by the process
void remove_temporary_directories (); void remove_temporary_directories ();
// Generic signal handler declarations // Generic signal handler declarations