From b72724a4a4205a9a113c87180790c3c0b4f82bb7 Mon Sep 17 00:00:00 2001 From: wilsonianb Date: Fri, 1 Jul 2016 14:51:22 -0700 Subject: [PATCH] Ignore empty CONFIG_DIR for validators file (RIPD-1221) --- src/ripple/core/impl/Config.cpp | 4 ++-- src/ripple/core/tests/Config.test.cpp | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ripple/core/impl/Config.cpp b/src/ripple/core/impl/Config.cpp index 9aabce2998..bc95f824e3 100644 --- a/src/ripple/core/impl/Config.cpp +++ b/src/ripple/core/impl/Config.cpp @@ -440,7 +440,7 @@ void Config::loadFromString (std::string const& fileContents) Throw ( "Invalid path specified in [" SECTION_VALIDATORS_FILE "]"); - if (!validatorsFile.is_absolute()) + if (!validatorsFile.is_absolute() && !CONFIG_DIR.empty()) validatorsFile = CONFIG_DIR / validatorsFile; if (!boost::filesystem::exists (validatorsFile)) @@ -454,7 +454,7 @@ void Config::loadFromString (std::string const& fileContents) "Invalid file specified in [" SECTION_VALIDATORS_FILE "]: " + validatorsFile.string()); } - else + else if (!CONFIG_DIR.empty()) { validatorsFile = CONFIG_DIR / validatorsFileName; diff --git a/src/ripple/core/tests/Config.test.cpp b/src/ripple/core/tests/Config.test.cpp index 9ce4e31a30..e6c3cf2159 100644 --- a/src/ripple/core/tests/Config.test.cpp +++ b/src/ripple/core/tests/Config.test.cpp @@ -141,7 +141,7 @@ protected: remove (toRm); else test_.log << "Expected " << toRm.string () - << " to be an empty existing directory."; + << " to be an empty existing directory." << std::endl; }; public: @@ -176,12 +176,13 @@ public: if (rmSubDir_) rmDir (subDir_); else - test_.log << "Skipping rm dir: " << subDir_.string (); + test_.log << "Skipping rm dir: " + << subDir_.string () << std::endl; } catch (std::exception& e) { // if we throw here, just let it die. - test_.log << "Error in ~ConfigGuard: " << e.what (); + test_.log << "Error in ~ConfigGuard: " << e.what () << std::endl; }; } }; @@ -249,19 +250,21 @@ public: using namespace boost::filesystem; if (!boost::filesystem::exists (configFile_)) test_.log << "Expected " << configFile_.string () - << " to be an existing file."; + << " to be an existing file." << std::endl; else remove (configFile_.string ()); if (rmDataDir_) rmDir (dataDir_); else - test_.log << "Skipping rm dir: " << dataDir_.string (); + test_.log << "Skipping rm dir: " + << dataDir_.string () << std::endl; } catch (std::exception& e) { // if we throw here, just let it die. - test_.log << "Error in ~RippledCfgGuard: " << e.what (); + test_.log << "Error in ~RippledCfgGuard: " + << e.what () << std::endl; }; } }; @@ -337,14 +340,15 @@ public: using namespace boost::filesystem; if (!boost::filesystem::exists (validatorsFile_)) test_.log << "Expected " << validatorsFile_.string () - << " to be an existing file."; + << " to be an existing file." << std::endl; else remove (validatorsFile_.string ()); } catch (std::exception& e) { // if we throw here, just let it die. - test_.log << "Error in ~ValidatorsTxtGuard: " << e.what (); + test_.log << "Error in ~ValidatorsTxtGuard: " + << e.what () << std::endl; }; } };