Merge #19533: [tests] Remove unnecessary cs_mains in denialofservice_tests

f58c4b538ebd67fcfea0a4aff5e062fd59fb19f5 [tests] Remove unnecessary cs_mains in denialofservice_tests (Matt Corallo)

Pull request description:

  9fdf05d70cac4a62d1aeeb4299e2c3a9a866f8af resolved some lock
  inversion warnings in denialofservice_tests, but left in a number
  of cs_main locks that are unnecessary (introducing lock inversion
  warnings in future changes).

ACKs for top commit:
  promag:
    ACK f58c4b538ebd67fcfea0a4aff5e062fd59fb19f5.
  jonatack:
    ACK f58c4b538ebd67fcfe verified the test locks correspond to the locks in net/net_processing, and the debug build is clean/unit tests pass.

Tree-SHA512: de2d9b2a8f08081b2ce31e18585e4677b167a11752b797d790c281575d7dfef3587f8be4fc7f8f16771141b6ff0b0145c7488cf30e79256b0043947c67a6182c
This commit is contained in:
MarcoFalke 2020-07-16 13:03:34 +02:00 committed by Pasta
parent f5abcec7b3
commit bbc53bf77c
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -97,11 +97,11 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
// Test starts here
{
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
LOCK(dummyNode1.cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); // should result in getheaders
}
{
LOCK2(cs_main, dummyNode1.cs_vSend);
LOCK(dummyNode1.cs_vSend);
BOOST_CHECK(dummyNode1.vSendMsg.size() > 0);
dummyNode1.vSendMsg.clear();
dummyNode1.nSendMsgSize = 0;
@ -111,17 +111,17 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
// Wait 21 minutes
SetMockTime(nStartTime+21*60);
{
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
LOCK(dummyNode1.cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); // should result in getheaders
}
{
LOCK2(cs_main, dummyNode1.cs_vSend);
LOCK(dummyNode1.cs_vSend);
BOOST_CHECK(dummyNode1.vSendMsg.size() > 0);
}
// Wait 3 more minutes
SetMockTime(nStartTime+24*60);
{
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
LOCK(dummyNode1.cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); // should result in disconnect
}
BOOST_CHECK(dummyNode1.fDisconnect == true);
@ -235,7 +235,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
Misbehaving(dummyNode1.GetId(), 100); // Should get banned
}
{
LOCK2(cs_main, dummyNode1.cs_sendProcessing);
LOCK(dummyNode1.cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(&dummyNode1));
}
BOOST_CHECK(banman->IsBanned(addr1));
@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
Misbehaving(dummyNode2.GetId(), 50);
}
{
LOCK2(cs_main, dummyNode2.cs_sendProcessing);
LOCK(dummyNode2.cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(&dummyNode2));
}
BOOST_CHECK(!banman->IsBanned(addr2)); // 2 not banned yet...
@ -262,7 +262,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
Misbehaving(dummyNode2.GetId(), 50);
}
{
LOCK2(cs_main, dummyNode2.cs_sendProcessing);
LOCK(dummyNode2.cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(&dummyNode2));
}
BOOST_CHECK(banman->IsBanned(addr2));
@ -341,7 +341,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
Misbehaving(dummyNode.GetId(), 100);
}
{
LOCK2(cs_main, dummyNode.cs_sendProcessing);
LOCK(dummyNode.cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(&dummyNode));
}
BOOST_CHECK(banman->IsBanned(addr));