Changeset View
Changeset View
Standalone View
Standalone View
src/test/denialofservice_tests.cpp
Show First 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(stale_tip_peer_management) { | ||||
connman->ClearNodes(); | connman->ClearNodes(); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(DoS_banning) { | BOOST_AUTO_TEST_CASE(DoS_banning) { | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
std::atomic<bool> interruptDummy(false); | std::atomic<bool> interruptDummy(false); | ||||
auto banman = std::make_unique<BanMan>(config.GetChainParams(), nullptr); | auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist.dat", | ||||
config.GetChainParams(), nullptr); | |||||
auto connman = std::make_unique<CConnman>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnman>(config, 0x1337, 0x1337); | ||||
auto peerLogic = std::make_unique<PeerLogicValidation>( | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
connman.get(), banman.get(), scheduler, false); | connman.get(), banman.get(), scheduler, false); | ||||
banman->ClearBanned(); | banman->ClearBanned(); | ||||
CAddress addr1(ip(0xa0b0c001), NODE_NONE); | CAddress addr1(ip(0xa0b0c001), NODE_NONE); | ||||
CNode dummyNode1(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr1, 0, 0, | CNode dummyNode1(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr1, 0, 0, | ||||
CAddress(), "", true); | CAddress(), "", true); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(DoS_banning) { | ||||
peerLogic->FinalizeNode(config, dummyNode1.GetId(), dummy); | peerLogic->FinalizeNode(config, dummyNode1.GetId(), dummy); | ||||
peerLogic->FinalizeNode(config, dummyNode2.GetId(), dummy); | peerLogic->FinalizeNode(config, dummyNode2.GetId(), dummy); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(DoS_banscore) { | BOOST_AUTO_TEST_CASE(DoS_banscore) { | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
std::atomic<bool> interruptDummy(false); | std::atomic<bool> interruptDummy(false); | ||||
auto banman = std::make_unique<BanMan>(config.GetChainParams(), nullptr); | auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist.dat", | ||||
config.GetChainParams(), nullptr); | |||||
auto connman = std::make_unique<CConnman>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnman>(config, 0x1337, 0x1337); | ||||
auto peerLogic = std::make_unique<PeerLogicValidation>( | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
connman.get(), banman.get(), scheduler, false); | connman.get(), banman.get(), scheduler, false); | ||||
banman->ClearBanned(); | banman->ClearBanned(); | ||||
// because 11 is my favorite number. | // because 11 is my favorite number. | ||||
gArgs.ForceSetArg("-banscore", "111"); | gArgs.ForceSetArg("-banscore", "111"); | ||||
CAddress addr1(ip(0xa0b0c001), NODE_NONE); | CAddress addr1(ip(0xa0b0c001), NODE_NONE); | ||||
Show All 35 Lines | BOOST_AUTO_TEST_CASE(DoS_banscore) { | ||||
bool dummy; | bool dummy; | ||||
peerLogic->FinalizeNode(config, dummyNode1.GetId(), dummy); | peerLogic->FinalizeNode(config, dummyNode1.GetId(), dummy); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(DoS_bantime) { | BOOST_AUTO_TEST_CASE(DoS_bantime) { | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
std::atomic<bool> interruptDummy(false); | std::atomic<bool> interruptDummy(false); | ||||
auto banman = std::make_unique<BanMan>(config.GetChainParams(), nullptr); | auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist.dat", | ||||
config.GetChainParams(), nullptr); | |||||
auto connman = std::make_unique<CConnman>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnman>(config, 0x1337, 0x1337); | ||||
auto peerLogic = std::make_unique<PeerLogicValidation>( | auto peerLogic = std::make_unique<PeerLogicValidation>( | ||||
connman.get(), banman.get(), scheduler, false); | connman.get(), banman.get(), scheduler, false); | ||||
banman->ClearBanned(); | banman->ClearBanned(); | ||||
int64_t nStartTime = GetTime(); | int64_t nStartTime = GetTime(); | ||||
// Overrides future calls to GetTime() | // Overrides future calls to GetTime() | ||||
SetMockTime(nStartTime); | SetMockTime(nStartTime); | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |