diff options
author | Martin Zumsande <mzumsande@gmail.com> | 2021-12-12 21:37:34 +0000 |
---|---|---|
committer | Martin Zumsande <mzumsande@gmail.com> | 2021-12-28 19:36:22 +0100 |
commit | 1c65d427bbf61bb558cf7e18f7aff99b19f68508 (patch) | |
tree | 28de7b0a31712dcd3895bd12876bac5222ad9262 /src/test/addrman_tests.cpp | |
parent | 5b7aac34f2363822c3a1cfafda8ffc9528905058 (diff) |
test: Inline SimConnFail function
No need for a function, since it is only used once.
Co-Authored-By: Amiti Uttarwar <amiti@uttarwar.org>
Diffstat (limited to 'src/test/addrman_tests.cpp')
-rw-r--r-- | src/test/addrman_tests.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index 4745d29f9f..4a877843ba 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -46,18 +46,6 @@ public: LOCK(m_impl->cs); m_impl->Delete(nId); } - - // Simulates connection failure so that we can test eviction of offline nodes - void SimConnFail(const CService& addr) - { - int64_t nLastSuccess = 1; - // Set last good connection in the deep past. - Good(addr, nLastSuccess); - - bool count_failure = false; - int64_t nLastTry = GetAdjustedTime() - 61; - Attempt(addr, count_failure, nLastTry); - } }; static CNetAddr ResolveIP(const std::string& ip) @@ -897,7 +885,9 @@ BOOST_AUTO_TEST_CASE(addrman_evictionworks) BOOST_CHECK_EQUAL(info.ToString(), "250.1.1.19:0"); // Ensure test of address fails, so that it is evicted. - addrman.SimConnFail(info); + // Update entry in tried by setting last good connection in the deep past. + BOOST_CHECK(!addrman.Good(info, /*nTime=*/1)); + addrman.Attempt(info, /*fCountFailure=*/false, /*nTime=*/GetAdjustedTime() - 61); // Should swap 36 for 19. addrman.ResolveCollisions(); |