mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
39 lines
1008 B
C++
39 lines
1008 B
C++
#include "util/AsioContextTestFixture.hpp"
|
|
#include "util/config/ConfigDefinition.hpp"
|
|
#include "util/config/ConfigValue.hpp"
|
|
#include "util/config/Types.hpp"
|
|
#include "web/dosguard/DOSGuardMock.hpp"
|
|
#include "web/dosguard/IntervalSweepHandler.hpp"
|
|
|
|
#include <gmock/gmock.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <chrono>
|
|
|
|
using namespace web::dosguard;
|
|
using namespace util::config;
|
|
|
|
struct IntervalSweepHandlerTest : SyncAsioContextTest {
|
|
protected:
|
|
static constexpr auto kJSON_DATA = R"JSON(
|
|
{
|
|
"dos_guard": {
|
|
"sweep_interval": 0
|
|
}
|
|
}
|
|
)JSON";
|
|
|
|
DOSGuardStrictMock guardMock_;
|
|
|
|
ClioConfigDefinition cfg_{
|
|
{"dos_guard.sweep_interval", ConfigValue{ConfigType::Integer}.defaultValue(0)}
|
|
};
|
|
IntervalSweepHandler sweepHandler_{cfg_, ctx_, guardMock_};
|
|
};
|
|
|
|
TEST_F(IntervalSweepHandlerTest, SweepAfterInterval)
|
|
{
|
|
EXPECT_CALL(guardMock_, clear()).Times(testing::AtLeast(10));
|
|
runContextFor(std::chrono::milliseconds{20});
|
|
}
|