diff options
author | fanquake <fanquake@gmail.com> | 2023-02-01 15:54:40 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-02-01 15:56:48 +0000 |
commit | 2d5acc901db336868dee158022a115b120b5b675 (patch) | |
tree | a7d16417876ad00380dc9ea158c387ceb07a200b /src | |
parent | 550e6bd227c365c396bbec454759c33d128b3ed1 (diff) | |
parent | dc70c1eb08ba8f0e77ac0810312a67468ade9419 (diff) |
Merge bitcoin/bitcoin#27015: p2p: 26847 fixups (AddrMan totals)
dc70c1eb08ba8f0e77ac0810312a67468ade9419 addrman: Use std::nullopt instead of {} (Martin Zumsande)
59cc66abb945c11f30fa571899127275528c5fce test: Remove AddrMan unit test that fails consistency checks (Martin Zumsande)
Pull request description:
Two fixups for #26847:
* Now that `AddrMan::Size()` performs internal consistency tests (it didn't before), we can't call it in the `load_addrman_corrupted` unit tests, where we deal with an artificially corrupted `AddrMan`. This would fail the test when using `-checkaddrman=1` (leading to spurious CI fails). Therefore remove the tests assertion, which is not particularly helpful anyway (in production we abort init when peers.dat is corrupted instead of querying AddrMan in its corrupted state).
(See https://github.com/bitcoin/bitcoin/pull/26847#issuecomment-1411458339)
* Use `std::nullopt` instead of `{}` for default args (suggested in https://github.com/bitcoin/bitcoin/pull/26847#discussion_r1090643603)
ACKs for top commit:
MarcoFalke:
lgtm ACK dc70c1eb08ba8f0e77ac0810312a67468ade9419
Tree-SHA512: dd8a988e23d71a66d3dd30560bb653c9ad17db6915abfa5f722818b0ab18921051ec9223bfbc75d967df8bcd204dfe473d680bf68e8a8e4e4998fbb91dc973c5
Diffstat (limited to 'src')
-rw-r--r-- | src/addrman.h | 2 | ||||
-rw-r--r-- | src/test/addrman_tests.cpp | 2 |
2 files changed, 1 insertions, 3 deletions
diff --git a/src/addrman.h b/src/addrman.h index 2a074268be..4985fc764c 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -106,7 +106,7 @@ public: * @param[in] in_new Select addresses only from one table (true = new, false = tried, nullopt = both) * @return Number of unique addresses that match specified options. */ - size_t Size(std::optional<Network> net = {}, std::optional<bool> in_new = {}) const; + size_t Size(std::optional<Network> net = std::nullopt, std::optional<bool> in_new = std::nullopt) const; /** * Attempt to add one or more addresses to addrman's new table. diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index cf7bb776cc..586cec4081 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -947,8 +947,6 @@ BOOST_AUTO_TEST_CASE(load_addrman_corrupted) } catch (const std::exception&) { exceptionThrown = true; } - // Even though de-serialization failed addrman is not left in a clean state. - BOOST_CHECK(addrman1.Size() == 1); BOOST_CHECK(exceptionThrown); // Test that ReadFromStream fails if peers.dat is corrupt |