forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #2686: [TierTwo] Introduce network requests manager
be1c0fc test: coverage for netfulfilledman requests existence and expiration. (furszy) 42f76c9 Connect net requests manager load, dump and maintenance job. (furszy) ad60ad7 Create fulfilled requests manager. (furszy) Pull request description: Built on top of #2684 An object in charge of cache and store tier two network requests information, preventing possible bans for asking the same data too often. ACKs for top commit: random-zebra: ACK be1c0fc Fuzzbawls: ACK be1c0fc Tree-SHA512: 9abb5f01372cf85af7d7e21c581394008d8e1cc941a3bf2b388c34b7fd2cff391f953fdf6ace8afed717c0ed3879e04bb102d6c1b9db884d895445639229c12b
- Loading branch information
Showing
15 changed files
with
231 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2022 The PIVX developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or https://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include "netbase.h" | ||
#include "test/test_pivx.h" | ||
#include "tiertwo/netfulfilledman.h" | ||
#include "utiltime.h" | ||
|
||
#include <boost/test/unit_test.hpp> | ||
|
||
BOOST_FIXTURE_TEST_SUITE(netfulfilledman_tests, RegTestingSetup) | ||
|
||
BOOST_AUTO_TEST_CASE(netfulfilledman_simple_add_and_expire) | ||
{ | ||
int64_t now = GetTime(); | ||
SetMockTime(now); | ||
|
||
CNetFulfilledRequestManager fulfilledMan; | ||
CService service = LookupNumeric("1.1.1.1", 9999); | ||
std::string request = "request"; | ||
BOOST_ASSERT(!fulfilledMan.HasFulfilledRequest(service, request)); | ||
|
||
// Add request | ||
fulfilledMan.AddFulfilledRequest(service, request); | ||
// Verify that the request is there | ||
BOOST_ASSERT(fulfilledMan.HasFulfilledRequest(service, request)); | ||
|
||
// Advance mock time to surpass FulfilledRequestExpireTime | ||
SetMockTime(now + 60 * 60 + 1); | ||
|
||
// Verify that the request exists and expired now | ||
BOOST_CHECK(fulfilledMan.Size() == 1); | ||
BOOST_CHECK(!fulfilledMan.HasFulfilledRequest(service, request)); | ||
|
||
// Verify request removal | ||
fulfilledMan.CheckAndRemove(); | ||
BOOST_CHECK(fulfilledMan.Size() == 0); | ||
} | ||
|
||
BOOST_AUTO_TEST_SUITE_END() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.