mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Isolate Application object in Env:
This change causes each instance of Env to construct its own isolated Application object for testing. Also included is part of a framework to create multiple Application objects in the same unit test and connect them together.
This commit is contained in:
@@ -50,17 +50,41 @@ namespace test {
|
||||
|
||||
namespace jtx {
|
||||
|
||||
Env::AppBundle::AppBundle(Application* app_)
|
||||
: app (app_)
|
||||
{
|
||||
}
|
||||
|
||||
Env::AppBundle::AppBundle(std::unique_ptr<Config const> config)
|
||||
{
|
||||
auto logs = std::make_unique<Logs>();
|
||||
owned = make_Application(
|
||||
std::move(config), std::move(logs));
|
||||
app = owned.get();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static
|
||||
std::unique_ptr<Config const>
|
||||
makeConfig()
|
||||
{
|
||||
auto p = std::make_unique<Config>();
|
||||
setupConfigForUnitTests(*p);
|
||||
return std::unique_ptr<Config const>(p.release());
|
||||
}
|
||||
|
||||
// VFALCO Could wrap the log in a Journal here
|
||||
Env::Env (beast::unit_test::suite& test_)
|
||||
: test(test_)
|
||||
, config()
|
||||
, master("master", generateKeyPair(
|
||||
: test (test_)
|
||||
, master ("master", generateKeyPair(
|
||||
KeyType::secp256k1,
|
||||
generateSeed("masterpassphrase")))
|
||||
, bundle_ (makeConfig())
|
||||
, closed_ (std::make_shared<Ledger>(
|
||||
create_genesis, config, app().family()))
|
||||
create_genesis, app().config(), app().family()))
|
||||
, cachedSLEs_ (std::chrono::seconds(5), stopwatch_)
|
||||
, openLedger (closed_, config, cachedSLEs_, journal)
|
||||
, openLedger (closed_, app().config(), cachedSLEs_, journal)
|
||||
{
|
||||
memoize(master);
|
||||
initializePathfinding();
|
||||
@@ -98,7 +122,7 @@ Env::close(NetClock::time_point const& closeTime)
|
||||
OpenView accum(&*next);
|
||||
OpenLedger::apply(app(), accum, *closed_,
|
||||
txs, retries, applyFlags(), *router,
|
||||
config, journal);
|
||||
app().config(), journal);
|
||||
accum.apply(*next);
|
||||
}
|
||||
// To ensure that the close time is exact and not rounded, we don't
|
||||
@@ -254,7 +278,7 @@ Env::submit (JTx const& jt)
|
||||
{
|
||||
std::tie(ter_, didApply) = ripple::apply(
|
||||
app(), view, *stx, applyFlags(),
|
||||
directSigVerify, config,
|
||||
directSigVerify, app().config(),
|
||||
beast::Journal{});
|
||||
return didApply;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user