mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix limit setting and add ServerImp tests (RIPD-1463,1458):
Add more test coverage for ServerHandlerImp.cpp. Ensure limit parameter is propagated from parsed object to in-memory config. Release Notes ------------- This fixes a bug whereby the limit parameter on a port configuration was ignored.
This commit is contained in:
@@ -55,81 +55,36 @@ namespace ripple {
|
||||
namespace test {
|
||||
namespace jtx {
|
||||
|
||||
class SuiteSink : public beast::Journal::Sink
|
||||
void
|
||||
SuiteSink::write(beast::severities::Severity level, std::string const& text)
|
||||
{
|
||||
std::string partition_;
|
||||
beast::unit_test::suite& suite_;
|
||||
|
||||
public:
|
||||
SuiteSink(std::string const& partition,
|
||||
beast::severities::Severity threshold,
|
||||
beast::unit_test::suite& suite)
|
||||
: Sink (threshold, false)
|
||||
, partition_(partition + " ")
|
||||
, suite_ (suite)
|
||||
using namespace beast::severities;
|
||||
std::string s;
|
||||
switch(level)
|
||||
{
|
||||
case kTrace: s = "TRC:"; break;
|
||||
case kDebug: s = "DBG:"; break;
|
||||
case kInfo: s = "INF:"; break;
|
||||
case kWarning: s = "WRN:"; break;
|
||||
case kError: s = "ERR:"; break;
|
||||
default:
|
||||
case kFatal: s = "FTL:"; break;
|
||||
}
|
||||
|
||||
// For unit testing, always generate logging text.
|
||||
bool active(beast::severities::Severity level) const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
write(beast::severities::Severity level,
|
||||
std::string const& text) override
|
||||
{
|
||||
using namespace beast::severities;
|
||||
std::string s;
|
||||
switch(level)
|
||||
{
|
||||
case kTrace: s = "TRC:"; break;
|
||||
case kDebug: s = "DBG:"; break;
|
||||
case kInfo: s = "INF:"; break;
|
||||
case kWarning: s = "WRN:"; break;
|
||||
case kError: s = "ERR:"; break;
|
||||
default:
|
||||
case kFatal: s = "FTL:"; break;
|
||||
}
|
||||
|
||||
// Only write the string if the level at least equals the threshold.
|
||||
if (level >= threshold())
|
||||
suite_.log << s << partition_ << text << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class SuiteLogs : public Logs
|
||||
{
|
||||
beast::unit_test::suite& suite_;
|
||||
|
||||
public:
|
||||
explicit
|
||||
SuiteLogs(beast::unit_test::suite& suite)
|
||||
: Logs (beast::severities::kError)
|
||||
, suite_(suite)
|
||||
{
|
||||
}
|
||||
|
||||
~SuiteLogs() override = default;
|
||||
|
||||
std::unique_ptr<beast::Journal::Sink>
|
||||
makeSink(std::string const& partition,
|
||||
beast::severities::Severity threshold) override
|
||||
{
|
||||
return std::make_unique<SuiteSink>(partition, threshold, suite_);
|
||||
}
|
||||
};
|
||||
// Only write the string if the level at least equals the threshold.
|
||||
if (level >= threshold())
|
||||
suite_.log << s << partition_ << text << std::endl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Env::AppBundle::AppBundle(beast::unit_test::suite& suite,
|
||||
std::unique_ptr<Config> config)
|
||||
std::unique_ptr<Config> config,
|
||||
std::unique_ptr<Logs> logs)
|
||||
{
|
||||
using namespace beast::severities;
|
||||
// Use kFatal threshold to reduce noise from STObject.
|
||||
setDebugLogSink (std::make_unique<SuiteSink>("Debug", kFatal, suite));
|
||||
auto logs = std::make_unique<SuiteLogs>(suite);
|
||||
auto timeKeeper_ =
|
||||
std::make_unique<ManualTimeKeeper>();
|
||||
timeKeeper = timeKeeper_.get();
|
||||
|
||||
Reference in New Issue
Block a user