Skip to content

Commit 1c65d42

Browse files
test: Inline SimConnFail function
No need for a function, since it is only used once. Co-Authored-By: Amiti Uttarwar <[email protected]>
1 parent 5b7aac3 commit 1c65d42

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/test/addrman_tests.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,6 @@ class AddrManTest : public AddrMan
4646
LOCK(m_impl->cs);
4747
m_impl->Delete(nId);
4848
}
49-
50-
// Simulates connection failure so that we can test eviction of offline nodes
51-
void SimConnFail(const CService& addr)
52-
{
53-
int64_t nLastSuccess = 1;
54-
// Set last good connection in the deep past.
55-
Good(addr, nLastSuccess);
56-
57-
bool count_failure = false;
58-
int64_t nLastTry = GetAdjustedTime() - 61;
59-
Attempt(addr, count_failure, nLastTry);
60-
}
6149
};
6250

6351
static CNetAddr ResolveIP(const std::string& ip)
@@ -897,7 +885,9 @@ BOOST_AUTO_TEST_CASE(addrman_evictionworks)
897885
BOOST_CHECK_EQUAL(info.ToString(), "250.1.1.19:0");
898886

899887
// Ensure test of address fails, so that it is evicted.
900-
addrman.SimConnFail(info);
888+
// Update entry in tried by setting last good connection in the deep past.
889+
BOOST_CHECK(!addrman.Good(info, /*nTime=*/1));
890+
addrman.Attempt(info, /*fCountFailure=*/false, /*nTime=*/GetAdjustedTime() - 61);
901891

902892
// Should swap 36 for 19.
903893
addrman.ResolveCollisions();

0 commit comments

Comments
 (0)