|
|
@ -232,14 +232,14 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
|
|
|
|
dummyNode1.fSuccessfullyConnected = true;
|
|
|
|
dummyNode1.fSuccessfullyConnected = true;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOCK(cs_main);
|
|
|
|
LOCK(cs_main);
|
|
|
|
Misbehaving(dummyNode1.GetId(), DEFAULT_BANSCORE_THRESHOLD); // Should get banned
|
|
|
|
Misbehaving(dummyNode1.GetId(), DISCOURAGEMENT_THRESHOLD); // Should be discouraged
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
|
|
|
|
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
|
|
|
|
BOOST_CHECK(peerLogic->SendMessages(&dummyNode1));
|
|
|
|
BOOST_CHECK(peerLogic->SendMessages(&dummyNode1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BOOST_CHECK(banman->IsDiscouraged(addr1));
|
|
|
|
BOOST_CHECK(banman->IsDiscouraged(addr1));
|
|
|
|
BOOST_CHECK(!banman->IsDiscouraged(ip(0xa0b0c001|0x0000ff00))); // Different IP, not banned
|
|
|
|
BOOST_CHECK(!banman->IsDiscouraged(ip(0xa0b0c001|0x0000ff00))); // Different IP, not discouraged
|
|
|
|
|
|
|
|
|
|
|
|
CAddress addr2(ip(0xa0b0c002), NODE_NONE);
|
|
|
|
CAddress addr2(ip(0xa0b0c002), NODE_NONE);
|
|
|
|
CNode dummyNode2(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr2, 1, 1, CAddress(), "", true);
|
|
|
|
CNode dummyNode2(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr2, 1, 1, CAddress(), "", true);
|
|
|
@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
|
|
|
|
LOCK2(cs_main, dummyNode2.cs_sendProcessing);
|
|
|
|
LOCK2(cs_main, dummyNode2.cs_sendProcessing);
|
|
|
|
BOOST_CHECK(peerLogic->SendMessages(&dummyNode2));
|
|
|
|
BOOST_CHECK(peerLogic->SendMessages(&dummyNode2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BOOST_CHECK(!banman->IsDiscouraged(addr2)); // 2 not banned yet...
|
|
|
|
BOOST_CHECK(!banman->IsDiscouraged(addr2)); // 2 not discouraged yet...
|
|
|
|
BOOST_CHECK(banman->IsDiscouraged(addr1)); // ... but 1 still should be
|
|
|
|
BOOST_CHECK(banman->IsDiscouraged(addr1)); // ... but 1 still should be
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOCK(cs_main);
|
|
|
|
LOCK(cs_main);
|
|
|
@ -287,7 +287,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
|
|
|
|
dummyNode1.fSuccessfullyConnected = true;
|
|
|
|
dummyNode1.fSuccessfullyConnected = true;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOCK(cs_main);
|
|
|
|
LOCK(cs_main);
|
|
|
|
Misbehaving(dummyNode1.GetId(), DEFAULT_BANSCORE_THRESHOLD - 11);
|
|
|
|
Misbehaving(dummyNode1.GetId(), DISCOURAGEMENT_THRESHOLD - 11);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
|
|
|
|
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
|
|
|
@ -336,7 +336,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOCK(cs_main);
|
|
|
|
LOCK(cs_main);
|
|
|
|
Misbehaving(dummyNode.GetId(), DEFAULT_BANSCORE_THRESHOLD);
|
|
|
|
Misbehaving(dummyNode.GetId(), DISCOURAGEMENT_THRESHOLD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOCK2(cs_main, dummyNode.cs_sendProcessing);
|
|
|
|
LOCK2(cs_main, dummyNode.cs_sendProcessing);
|
|
|
|