Browse Source

Merge #10765: Tests: address placement should be deterministic by default

c5ebddd11 Tests: address placement should be deterministic by default (René Nyffenegger)

Pull request description:

  Better version of wrong and closed pull request https://github.com/bitcoin/bitcoin/pull/10764

Tree-SHA512: dfda6ea4a9dd0f4c8b96212ad43a716ff1dddf115cd2712a2a7e42c97fc9494079c746906b39d880a9827c05d2b75c728afd4ca4519ce4d365f0dae0c4aec24c
0.15
MarcoFalke 7 years ago
parent
commit
2c811e08db
No known key found for this signature in database
GPG Key ID: D2EA4850E7528B25
  1. 40
      src/test/addrman_tests.cpp

40
src/test/addrman_tests.cpp

@ -15,9 +15,14 @@ class CAddrManTest : public CAddrMan @@ -15,9 +15,14 @@ class CAddrManTest : public CAddrMan
uint64_t state;
public:
CAddrManTest()
CAddrManTest(bool makeDeterministic = true)
{
state = 1;
if (makeDeterministic) {
// Set addrman addr placement to be deterministic.
MakeDeterministic();
}
}
//! Ensure that bucket placement is always the same for testing purposes.
@ -79,9 +84,6 @@ BOOST_AUTO_TEST_CASE(addrman_simple) @@ -79,9 +84,6 @@ BOOST_AUTO_TEST_CASE(addrman_simple)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
CNetAddr source = ResolveIP("252.2.2.2");
// Test: Does Addrman respond correctly when empty.
@ -131,9 +133,6 @@ BOOST_AUTO_TEST_CASE(addrman_ports) @@ -131,9 +133,6 @@ BOOST_AUTO_TEST_CASE(addrman_ports)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
CNetAddr source = ResolveIP("252.2.2.2");
BOOST_CHECK_EQUAL(addrman.size(), 0);
@ -163,9 +162,6 @@ BOOST_AUTO_TEST_CASE(addrman_select) @@ -163,9 +162,6 @@ BOOST_AUTO_TEST_CASE(addrman_select)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
CNetAddr source = ResolveIP("252.2.2.2");
// Test: Select from new with 1 addr in new.
@ -225,9 +221,6 @@ BOOST_AUTO_TEST_CASE(addrman_new_collisions) @@ -225,9 +221,6 @@ BOOST_AUTO_TEST_CASE(addrman_new_collisions)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
CNetAddr source = ResolveIP("252.2.2.2");
BOOST_CHECK_EQUAL(addrman.size(), 0);
@ -254,9 +247,6 @@ BOOST_AUTO_TEST_CASE(addrman_tried_collisions) @@ -254,9 +247,6 @@ BOOST_AUTO_TEST_CASE(addrman_tried_collisions)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
CNetAddr source = ResolveIP("252.2.2.2");
BOOST_CHECK_EQUAL(addrman.size(), 0);
@ -284,9 +274,6 @@ BOOST_AUTO_TEST_CASE(addrman_find) @@ -284,9 +274,6 @@ BOOST_AUTO_TEST_CASE(addrman_find)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
BOOST_CHECK_EQUAL(addrman.size(), 0);
CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE);
@ -320,9 +307,6 @@ BOOST_AUTO_TEST_CASE(addrman_create) @@ -320,9 +307,6 @@ BOOST_AUTO_TEST_CASE(addrman_create)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
BOOST_CHECK_EQUAL(addrman.size(), 0);
CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE);
@ -343,9 +327,6 @@ BOOST_AUTO_TEST_CASE(addrman_delete) @@ -343,9 +327,6 @@ BOOST_AUTO_TEST_CASE(addrman_delete)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
BOOST_CHECK_EQUAL(addrman.size(), 0);
CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE);
@ -366,9 +347,6 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr) @@ -366,9 +347,6 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
// Test: Sanity check, GetAddr should never return anything if addrman
// is empty.
BOOST_CHECK_EQUAL(addrman.size(), 0);
@ -430,9 +408,6 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket) @@ -430,9 +408,6 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
CAddress addr1 = CAddress(ResolveService("250.1.1.1", 8333), NODE_NONE);
CAddress addr2 = CAddress(ResolveService("250.1.1.1", 9999), NODE_NONE);
@ -487,9 +462,6 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket) @@ -487,9 +462,6 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket)
{
CAddrManTest addrman;
// Set addrman addr placement to be deterministic.
addrman.MakeDeterministic();
CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE);
CAddress addr2 = CAddress(ResolveService("250.1.2.1", 9999), NODE_NONE);

Loading…
Cancel
Save