aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2024-03-25 10:04:01 +0000
committerfanquake <fanquake@gmail.com>2024-03-25 10:48:05 +0000
commitf22bca6473218d687210341f49c95d89c035547d (patch)
treed10ca06059c7bd4485baf92d46a6d6eb4125f5e5
parentc1223188e0a5fb11c3a1b9224511a49dc2f848ed (diff)
parent9a44a20fb790f3be5d5d5d8f5d0f48aac633b2a4 (diff)
Merge bitcoin/bitcoin#29636: test: #29007 follow ups
9a44a20fb790f3be5d5d5d8f5d0f48aac633b2a4 init: clarify -test error (0xb10c) 3047c3e3a99112c38f118034daa672db70fa4a60 addrman: drop /*deterministic=*/ comment (0xb10c) 89b84ea91ae40876a52879c509c63d0bacbfaade test: check that addrman seeding is successful (0xb10c) Pull request description: A few, small follow-ups to #29007. See commit messages for details. ACKs for top commit: maflcko: lgtm ACK 9a44a20fb790f3be5d5d5d8f5d0f48aac633b2a4 stratospher: tested ACK 9a44a20. mzumsande: Code Review ACK 9a44a20fb790f3be5d5d5d8f5d0f48aac633b2a4 Tree-SHA512: 987245e035da08fa7fe541a1dc3b7c2d90f703a6f9813875048d286335c63ffa5201db702a3f368087c00fa02c3fdafb06cf54dc7a92922749a94588b1500e98
-rw-r--r--src/addrdb.cpp6
-rw-r--r--src/init.cpp2
-rwxr-xr-xtest/functional/rpc_net.py20
3 files changed, 16 insertions, 12 deletions
diff --git a/src/addrdb.cpp b/src/addrdb.cpp
index f8d4240f3f..14dc314c36 100644
--- a/src/addrdb.cpp
+++ b/src/addrdb.cpp
@@ -195,7 +195,7 @@ util::Result<std::unique_ptr<AddrMan>> LoadAddrman(const NetGroupManager& netgro
auto check_addrman = std::clamp<int32_t>(args.GetIntArg("-checkaddrman", DEFAULT_ADDRMAN_CONSISTENCY_CHECKS), 0, 1000000);
bool deterministic = HasTestOption(args, "addrman"); // use a deterministic addrman only for tests
- auto addrman{std::make_unique<AddrMan>(netgroupman, /*deterministic=*/deterministic, /*consistency_check_ratio=*/check_addrman)};
+ auto addrman{std::make_unique<AddrMan>(netgroupman, deterministic, /*consistency_check_ratio=*/check_addrman)};
const auto start{SteadyClock::now()};
const auto path_addr{args.GetDataDirNet() / "peers.dat"};
@@ -204,7 +204,7 @@ util::Result<std::unique_ptr<AddrMan>> LoadAddrman(const NetGroupManager& netgro
LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman->Size(), Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
} catch (const DbNotFoundError&) {
// Addrman can be in an inconsistent state after failure, reset it
- addrman = std::make_unique<AddrMan>(netgroupman, /*deterministic=*/deterministic, /*consistency_check_ratio=*/check_addrman);
+ addrman = std::make_unique<AddrMan>(netgroupman, deterministic, /*consistency_check_ratio=*/check_addrman);
LogPrintf("Creating peers.dat because the file was not found (%s)\n", fs::quoted(fs::PathToString(path_addr)));
DumpPeerAddresses(args, *addrman);
} catch (const InvalidAddrManVersionError&) {
@@ -212,7 +212,7 @@ util::Result<std::unique_ptr<AddrMan>> LoadAddrman(const NetGroupManager& netgro
return util::Error{strprintf(_("Failed to rename invalid peers.dat file. Please move or delete it and try again."))};
}
// Addrman can be in an inconsistent state after failure, reset it
- addrman = std::make_unique<AddrMan>(netgroupman, /*deterministic=*/deterministic, /*consistency_check_ratio=*/check_addrman);
+ addrman = std::make_unique<AddrMan>(netgroupman, deterministic, /*consistency_check_ratio=*/check_addrman);
LogPrintf("Creating new peers.dat because the file version was not compatible (%s). Original backed up to peers.dat.bak\n", fs::quoted(fs::PathToString(path_addr)));
DumpPeerAddresses(args, *addrman);
} catch (const std::exception& e) {
diff --git a/src/init.cpp b/src/init.cpp
index 349d4ff1ab..885c0673dd 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1031,7 +1031,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
if (args.IsArgSet("-test")) {
if (chainparams.GetChainType() != ChainType::REGTEST) {
- return InitError(Untranslated("-test=<option> should only be used in functional tests"));
+ return InitError(Untranslated("-test=<option> can only be used with regtest"));
}
const std::vector<std::string> options = args.GetArgs("-test");
for (const std::string& option : options) {
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 48d86ab59d..2701d2471d 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -45,14 +45,18 @@ def seed_addrman(node):
""" Populate the addrman with addresses from different networks.
Here 2 ipv4, 2 ipv6, 1 cjdns, 2 onion and 1 i2p addresses are added.
"""
- node.addpeeraddress(address="1.2.3.4", tried=True, port=8333)
- node.addpeeraddress(address="2.0.0.0", port=8333)
- node.addpeeraddress(address="1233:3432:2434:2343:3234:2345:6546:4534", tried=True, port=8333)
- node.addpeeraddress(address="2803:0:1234:abcd::1", port=45324)
- node.addpeeraddress(address="fc00:1:2:3:4:5:6:7", port=8333)
- node.addpeeraddress(address="pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion", tried=True, port=8333)
- node.addpeeraddress(address="nrfj6inpyf73gpkyool35hcmne5zwfmse3jl3aw23vk7chdemalyaqad.onion", port=45324, tried=True)
- node.addpeeraddress(address="c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p", port=8333)
+ # These addresses currently don't collide with a deterministic addrman.
+ # If the addrman positioning/bucketing is changed, these might collide
+ # and adding them fails.
+ success = { "success": True }
+ assert_equal(node.addpeeraddress(address="1.2.3.4", tried=True, port=8333), success)
+ assert_equal(node.addpeeraddress(address="2.0.0.0", port=8333), success)
+ assert_equal(node.addpeeraddress(address="1233:3432:2434:2343:3234:2345:6546:4534", tried=True, port=8333), success)
+ assert_equal(node.addpeeraddress(address="2803:0:1234:abcd::1", port=45324), success)
+ assert_equal(node.addpeeraddress(address="fc00:1:2:3:4:5:6:7", port=8333), success)
+ assert_equal(node.addpeeraddress(address="pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion", tried=True, port=8333), success)
+ assert_equal(node.addpeeraddress(address="nrfj6inpyf73gpkyool35hcmne5zwfmse3jl3aw23vk7chdemalyaqad.onion", port=45324, tried=True), success)
+ assert_equal(node.addpeeraddress(address="c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p", port=8333), success)
class NetTest(BitcoinTestFramework):