mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-17 05:30:43 +02:00
test: Inline SimConnFail function
No need for a function, since it is only used once. Co-Authored-By: Amiti Uttarwar <amiti@uttarwar.org>
This commit is contained in:
parent
5b7aac34f2
commit
1c65d427bb
@ -46,18 +46,6 @@ public:
|
|||||||
LOCK(m_impl->cs);
|
LOCK(m_impl->cs);
|
||||||
m_impl->Delete(nId);
|
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)
|
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");
|
BOOST_CHECK_EQUAL(info.ToString(), "250.1.1.19:0");
|
||||||
|
|
||||||
// Ensure test of address fails, so that it is evicted.
|
// 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.
|
// Should swap 36 for 19.
|
||||||
addrman.ResolveCollisions();
|
addrman.ResolveCollisions();
|
||||||
|
Loading…
Reference in New Issue
Block a user