mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Do not pass chain params to CheckForStaleTipAndEvictPeers twice
This commit is contained in:
@@ -153,7 +153,6 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
auto connman = MakeUnique<CConnmanTest>(0x1337, 0x1337);
|
||||
auto peerLogic = MakeUnique<PeerManager>(chainparams, *connman, nullptr, *m_node.scheduler, *m_node.chainman, *m_node.mempool);
|
||||
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
constexpr int max_outbound_full_relay = MAX_OUTBOUND_FULL_RELAY_CONNECTIONS;
|
||||
CConnman::Options options;
|
||||
options.nMaxConnections = DEFAULT_MAX_PEER_CONNECTIONS;
|
||||
@@ -168,18 +167,18 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
AddRandomOutboundPeer(vNodes, *peerLogic, connman.get());
|
||||
}
|
||||
|
||||
peerLogic->CheckForStaleTipAndEvictPeers(consensusParams);
|
||||
peerLogic->CheckForStaleTipAndEvictPeers();
|
||||
|
||||
// No nodes should be marked for disconnection while we have no extra peers
|
||||
for (const CNode *node : vNodes) {
|
||||
BOOST_CHECK(node->fDisconnect == false);
|
||||
}
|
||||
|
||||
SetMockTime(GetTime() + 3*consensusParams.nPowTargetSpacing + 1);
|
||||
SetMockTime(GetTime() + 3 * chainparams.GetConsensus().nPowTargetSpacing + 1);
|
||||
|
||||
// Now tip should definitely be stale, and we should look for an extra
|
||||
// outbound peer
|
||||
peerLogic->CheckForStaleTipAndEvictPeers(consensusParams);
|
||||
peerLogic->CheckForStaleTipAndEvictPeers();
|
||||
BOOST_CHECK(connman->GetTryNewOutboundPeer());
|
||||
|
||||
// Still no peers should be marked for disconnection
|
||||
@@ -192,8 +191,8 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
// required time connected check should be satisfied).
|
||||
AddRandomOutboundPeer(vNodes, *peerLogic, connman.get());
|
||||
|
||||
peerLogic->CheckForStaleTipAndEvictPeers(consensusParams);
|
||||
for (int i=0; i<max_outbound_full_relay; ++i) {
|
||||
peerLogic->CheckForStaleTipAndEvictPeers();
|
||||
for (int i = 0; i < max_outbound_full_relay; ++i) {
|
||||
BOOST_CHECK(vNodes[i]->fDisconnect == false);
|
||||
}
|
||||
// Last added node should get marked for eviction
|
||||
@@ -205,8 +204,8 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
// peer, and check that the next newest node gets evicted.
|
||||
UpdateLastBlockAnnounceTime(vNodes.back()->GetId(), GetTime());
|
||||
|
||||
peerLogic->CheckForStaleTipAndEvictPeers(consensusParams);
|
||||
for (int i=0; i<max_outbound_full_relay-1; ++i) {
|
||||
peerLogic->CheckForStaleTipAndEvictPeers();
|
||||
for (int i = 0; i < max_outbound_full_relay - 1; ++i) {
|
||||
BOOST_CHECK(vNodes[i]->fDisconnect == false);
|
||||
}
|
||||
BOOST_CHECK(vNodes[max_outbound_full_relay-1]->fDisconnect == true);
|
||||
|
||||
Reference in New Issue
Block a user