Add helper to modify Env configs (RIPD-1247)

Add envconfig test helper for manipulating Env config via
callables. Create new common modifiers for non-admin config,
validator config and one for using different server port values.
This commit is contained in:
Mike Ellery
2017-02-07 12:00:24 -08:00
committed by Scott Schurr
parent 09a1d1a593
commit 80d9b0464a
22 changed files with 304 additions and 249 deletions

View File

@@ -25,6 +25,7 @@
#include <ripple/core/SociDB.h>
#include <ripple/protocol/JsonFields.h>
#include <test/jtx.h>
#include <test/jtx/envconfig.h>
namespace ripple {
namespace test {
@@ -34,26 +35,24 @@ class SHAMapStore_test : public beast::unit_test::suite
static auto const deleteInterval = 8;
static
std::unique_ptr<Config>
makeConfig()
auto
onlineDelete(std::unique_ptr<Config> cfg)
{
auto p = std::make_unique<Config>();
setupConfigForUnitTests(*p);
p->LEDGER_HISTORY = deleteInterval;
auto& section = p->section(ConfigSection::nodeDatabase());
cfg->LEDGER_HISTORY = deleteInterval;
auto& section = cfg->section(ConfigSection::nodeDatabase());
section.set("online_delete", to_string(deleteInterval));
//section.set("age_threshold", "60");
return p;
return cfg;
}
static
std::unique_ptr<Config>
makeConfigAdvisory()
auto
advisoryDelete(std::unique_ptr<Config> cfg)
{
auto p = makeConfig();
auto& section = p->section(ConfigSection::nodeDatabase());
section.set("advisory_delete", "1");
return p;
cfg = onlineDelete(std::move(cfg));
cfg->section(ConfigSection::nodeDatabase())
.set("advisory_delete", "1");
return cfg;
}
bool goodLedger(jtx::Env& env, Json::Value const& json,
@@ -211,7 +210,7 @@ public:
testcase("clearPrior");
using namespace jtx;
Env env(*this, makeConfig());
Env env(*this, envconfig(onlineDelete));
auto& store = env.app().getSHAMapStore();
env.fund(XRP(10000), noripple("alice"));
@@ -397,7 +396,7 @@ public:
using namespace jtx;
using namespace std::chrono_literals;
Env env(*this, makeConfig());
Env env(*this, envconfig(onlineDelete));
auto& store = env.app().getSHAMapStore();
auto ledgerSeq = waitForReady(env);
@@ -466,7 +465,7 @@ public:
using namespace std::chrono_literals;
// Same config with advisory_delete enabled
Env env(*this, makeConfigAdvisory());
Env env(*this, envconfig(advisoryDelete));
auto& store = env.app().getSHAMapStore();
auto ledgerSeq = waitForReady(env);