mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
test: add tests for inbound eviction protection of I2P peers
This commit is contained in:
parent
ce02dd1ef1
commit
7c2284eda2
@ -157,6 +157,29 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
|
||||
/* unprotected_peer_ids */ {3, 4, 5, 6, 10, 11},
|
||||
random_context));
|
||||
|
||||
// Expect 1/4 I2P peers to be protected from eviction,
|
||||
// if no onion or localhost peers.
|
||||
BOOST_CHECK(IsProtected(
|
||||
num_peers, [](NodeEvictionCandidate& c) {
|
||||
c.m_is_local = false;
|
||||
c.m_network = (c.id == 2 || c.id == 7 || c.id == 10) ? NET_I2P : NET_IPV4;
|
||||
},
|
||||
/* protected_peer_ids */ {2, 7, 10},
|
||||
/* unprotected_peer_ids */ {},
|
||||
random_context));
|
||||
|
||||
// Expect 1/4 I2P peers and 1/4 of the other peers to be protected,
|
||||
// sorted by longest uptime (lowest nTimeConnected), if no onion or localhost peers.
|
||||
BOOST_CHECK(IsProtected(
|
||||
num_peers, [](NodeEvictionCandidate& c) {
|
||||
c.nTimeConnected = c.id;
|
||||
c.m_is_local = false;
|
||||
c.m_network = (c.id == 4 || c.id > 8) ? NET_I2P : NET_IPV6;
|
||||
},
|
||||
/* protected_peer_ids */ {0, 1, 2, 4, 9, 10},
|
||||
/* unprotected_peer_ids */ {3, 5, 6, 7, 8, 11},
|
||||
random_context));
|
||||
|
||||
// Tests with 2 networks...
|
||||
|
||||
// Combined test: expect having 1 localhost and 1 onion peer out of 4 to
|
||||
|
Loading…
Reference in New Issue
Block a user