|
|
@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning) |
|
|
|
CNode dummyNode1(INVALID_SOCKET, addr1, "", true); |
|
|
|
CNode dummyNode1(INVALID_SOCKET, addr1, "", true); |
|
|
|
dummyNode1.nVersion = 1; |
|
|
|
dummyNode1.nVersion = 1; |
|
|
|
Misbehaving(dummyNode1.GetId(), 100); // Should get banned
|
|
|
|
Misbehaving(dummyNode1.GetId(), 100); // Should get banned
|
|
|
|
SendMessages(&dummyNode1, false); |
|
|
|
SendMessages(&dummyNode1); |
|
|
|
BOOST_CHECK(CNode::IsBanned(addr1)); |
|
|
|
BOOST_CHECK(CNode::IsBanned(addr1)); |
|
|
|
BOOST_CHECK(!CNode::IsBanned(ip(0xa0b0c001|0x0000ff00))); // Different IP, not banned
|
|
|
|
BOOST_CHECK(!CNode::IsBanned(ip(0xa0b0c001|0x0000ff00))); // Different IP, not banned
|
|
|
|
|
|
|
|
|
|
|
@ -57,11 +57,11 @@ BOOST_AUTO_TEST_CASE(DoS_banning) |
|
|
|
CNode dummyNode2(INVALID_SOCKET, addr2, "", true); |
|
|
|
CNode dummyNode2(INVALID_SOCKET, addr2, "", true); |
|
|
|
dummyNode2.nVersion = 1; |
|
|
|
dummyNode2.nVersion = 1; |
|
|
|
Misbehaving(dummyNode2.GetId(), 50); |
|
|
|
Misbehaving(dummyNode2.GetId(), 50); |
|
|
|
SendMessages(&dummyNode2, false); |
|
|
|
SendMessages(&dummyNode2); |
|
|
|
BOOST_CHECK(!CNode::IsBanned(addr2)); // 2 not banned yet...
|
|
|
|
BOOST_CHECK(!CNode::IsBanned(addr2)); // 2 not banned yet...
|
|
|
|
BOOST_CHECK(CNode::IsBanned(addr1)); // ... but 1 still should be
|
|
|
|
BOOST_CHECK(CNode::IsBanned(addr1)); // ... but 1 still should be
|
|
|
|
Misbehaving(dummyNode2.GetId(), 50); |
|
|
|
Misbehaving(dummyNode2.GetId(), 50); |
|
|
|
SendMessages(&dummyNode2, false); |
|
|
|
SendMessages(&dummyNode2); |
|
|
|
BOOST_CHECK(CNode::IsBanned(addr2)); |
|
|
|
BOOST_CHECK(CNode::IsBanned(addr2)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -73,13 +73,13 @@ BOOST_AUTO_TEST_CASE(DoS_banscore) |
|
|
|
CNode dummyNode1(INVALID_SOCKET, addr1, "", true); |
|
|
|
CNode dummyNode1(INVALID_SOCKET, addr1, "", true); |
|
|
|
dummyNode1.nVersion = 1; |
|
|
|
dummyNode1.nVersion = 1; |
|
|
|
Misbehaving(dummyNode1.GetId(), 100); |
|
|
|
Misbehaving(dummyNode1.GetId(), 100); |
|
|
|
SendMessages(&dummyNode1, false); |
|
|
|
SendMessages(&dummyNode1); |
|
|
|
BOOST_CHECK(!CNode::IsBanned(addr1)); |
|
|
|
BOOST_CHECK(!CNode::IsBanned(addr1)); |
|
|
|
Misbehaving(dummyNode1.GetId(), 10); |
|
|
|
Misbehaving(dummyNode1.GetId(), 10); |
|
|
|
SendMessages(&dummyNode1, false); |
|
|
|
SendMessages(&dummyNode1); |
|
|
|
BOOST_CHECK(!CNode::IsBanned(addr1)); |
|
|
|
BOOST_CHECK(!CNode::IsBanned(addr1)); |
|
|
|
Misbehaving(dummyNode1.GetId(), 1); |
|
|
|
Misbehaving(dummyNode1.GetId(), 1); |
|
|
|
SendMessages(&dummyNode1, false); |
|
|
|
SendMessages(&dummyNode1); |
|
|
|
BOOST_CHECK(CNode::IsBanned(addr1)); |
|
|
|
BOOST_CHECK(CNode::IsBanned(addr1)); |
|
|
|
mapArgs.erase("-banscore"); |
|
|
|
mapArgs.erase("-banscore"); |
|
|
|
} |
|
|
|
} |
|
|
@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime) |
|
|
|
dummyNode.nVersion = 1; |
|
|
|
dummyNode.nVersion = 1; |
|
|
|
|
|
|
|
|
|
|
|
Misbehaving(dummyNode.GetId(), 100); |
|
|
|
Misbehaving(dummyNode.GetId(), 100); |
|
|
|
SendMessages(&dummyNode, false); |
|
|
|
SendMessages(&dummyNode); |
|
|
|
BOOST_CHECK(CNode::IsBanned(addr)); |
|
|
|
BOOST_CHECK(CNode::IsBanned(addr)); |
|
|
|
|
|
|
|
|
|
|
|
SetMockTime(nStartTime+60*60); |
|
|
|
SetMockTime(nStartTime+60*60); |
|
|
|