scripted-diff: Use clang-tidy syntax for C++ named arguments

-BEGIN VERIFY SCRIPT-
 perl -0777 -pi -e 's:((\(|\{|,)(\n| )*)\/\* ?([^=* ]+) ?\*\/ ?:\1/*\4=*/:g' $( git ls-files ./src/test ./src/wallet/test )
-END VERIFY SCRIPT-
This commit is contained in:
MarcoFalke 2021-09-14 16:56:34 +02:00
parent fae13c3989
commit fa00447442
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
29 changed files with 165 additions and 165 deletions

View File

@ -26,7 +26,7 @@ class AddrManTest : public AddrMan
{ {
public: public:
explicit AddrManTest(std::vector<bool> asmap = std::vector<bool>()) explicit AddrManTest(std::vector<bool> asmap = std::vector<bool>())
: AddrMan(asmap, /*deterministic=*/true, /* consistency_check_ratio */ 100) : AddrMan(asmap, /*deterministic=*/true, /*consistency_check_ratio=*/100)
{} {}
AddrInfo* Find(const CService& addr) AddrInfo* Find(const CService& addr)
@ -376,7 +376,7 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr)
// Test: Sanity check, GetAddr should never return anything if addrman // Test: Sanity check, GetAddr should never return anything if addrman
// is empty. // is empty.
BOOST_CHECK_EQUAL(addrman.size(), 0U); BOOST_CHECK_EQUAL(addrman.size(), 0U);
std::vector<CAddress> vAddr1 = addrman.GetAddr(/* max_addresses */ 0, /* max_pct */ 0, /* network */ std::nullopt); std::vector<CAddress> vAddr1 = addrman.GetAddr(/*max_addresses=*/0, /*max_pct=*/0, /*network=*/std::nullopt);
BOOST_CHECK_EQUAL(vAddr1.size(), 0U); BOOST_CHECK_EQUAL(vAddr1.size(), 0U);
CAddress addr1 = CAddress(ResolveService("250.250.2.1", 8333), NODE_NONE); CAddress addr1 = CAddress(ResolveService("250.250.2.1", 8333), NODE_NONE);
@ -396,15 +396,15 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr)
BOOST_CHECK(addrman.Add({addr1, addr3, addr5}, source1)); BOOST_CHECK(addrman.Add({addr1, addr3, addr5}, source1));
BOOST_CHECK(addrman.Add({addr2, addr4}, source2)); BOOST_CHECK(addrman.Add({addr2, addr4}, source2));
BOOST_CHECK_EQUAL(addrman.GetAddr(/* max_addresses */ 0, /* max_pct */ 0, /* network */ std::nullopt).size(), 5U); BOOST_CHECK_EQUAL(addrman.GetAddr(/*max_addresses=*/0, /*max_pct=*/0, /*network=*/std::nullopt).size(), 5U);
// Net processing asks for 23% of addresses. 23% of 5 is 1 rounded down. // Net processing asks for 23% of addresses. 23% of 5 is 1 rounded down.
BOOST_CHECK_EQUAL(addrman.GetAddr(/* max_addresses */ 2500, /* max_pct */ 23, /* network */ std::nullopt).size(), 1U); BOOST_CHECK_EQUAL(addrman.GetAddr(/*max_addresses=*/2500, /*max_pct=*/23, /*network=*/std::nullopt).size(), 1U);
// Test: Ensure GetAddr works with new and tried addresses. // Test: Ensure GetAddr works with new and tried addresses.
addrman.Good(CAddress(addr1, NODE_NONE)); addrman.Good(CAddress(addr1, NODE_NONE));
addrman.Good(CAddress(addr2, NODE_NONE)); addrman.Good(CAddress(addr2, NODE_NONE));
BOOST_CHECK_EQUAL(addrman.GetAddr(/* max_addresses */ 0, /* max_pct */ 0, /* network */ std::nullopt).size(), 5U); BOOST_CHECK_EQUAL(addrman.GetAddr(/*max_addresses=*/0, /*max_pct=*/0, /*network=*/std::nullopt).size(), 5U);
BOOST_CHECK_EQUAL(addrman.GetAddr(/* max_addresses */ 2500, /* max_pct */ 23, /* network */ std::nullopt).size(), 1U); BOOST_CHECK_EQUAL(addrman.GetAddr(/*max_addresses=*/2500, /*max_pct=*/23, /*network=*/std::nullopt).size(), 1U);
// Test: Ensure GetAddr still returns 23% when addrman has many addrs. // Test: Ensure GetAddr still returns 23% when addrman has many addrs.
for (unsigned int i = 1; i < (8 * 256); i++) { for (unsigned int i = 1; i < (8 * 256); i++) {
@ -419,7 +419,7 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr)
if (i % 8 == 0) if (i % 8 == 0)
addrman.Good(addr); addrman.Good(addr);
} }
std::vector<CAddress> vAddr = addrman.GetAddr(/* max_addresses */ 2500, /* max_pct */ 23, /* network */ std::nullopt); std::vector<CAddress> vAddr = addrman.GetAddr(/*max_addresses=*/2500, /*max_pct=*/23, /*network=*/std::nullopt);
size_t percent23 = (addrman.size() * 23) / 100; size_t percent23 = (addrman.size() * 23) / 100;
BOOST_CHECK_EQUAL(vAddr.size(), percent23); BOOST_CHECK_EQUAL(vAddr.size(), percent23);
@ -973,7 +973,7 @@ BOOST_AUTO_TEST_CASE(load_addrman)
// Test that the de-serialization does not throw an exception. // Test that the de-serialization does not throw an exception.
CDataStream ssPeers1 = AddrmanToStream(addrman); CDataStream ssPeers1 = AddrmanToStream(addrman);
bool exceptionThrown = false; bool exceptionThrown = false;
AddrMan addrman1(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 100); AddrMan addrman1(/*asmap=*/std::vector<bool>(), /*deterministic=*/false, /*consistency_check_ratio=*/100);
BOOST_CHECK(addrman1.size() == 0); BOOST_CHECK(addrman1.size() == 0);
try { try {
@ -990,7 +990,7 @@ BOOST_AUTO_TEST_CASE(load_addrman)
// Test that ReadFromStream creates an addrman with the correct number of addrs. // Test that ReadFromStream creates an addrman with the correct number of addrs.
CDataStream ssPeers2 = AddrmanToStream(addrman); CDataStream ssPeers2 = AddrmanToStream(addrman);
AddrMan addrman2(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 100); AddrMan addrman2(/*asmap=*/std::vector<bool>(), /*deterministic=*/false, /*consistency_check_ratio=*/100);
BOOST_CHECK(addrman2.size() == 0); BOOST_CHECK(addrman2.size() == 0);
ReadFromStream(addrman2, ssPeers2); ReadFromStream(addrman2, ssPeers2);
BOOST_CHECK(addrman2.size() == 3); BOOST_CHECK(addrman2.size() == 3);
@ -1028,7 +1028,7 @@ BOOST_AUTO_TEST_CASE(load_addrman_corrupted)
// Test that the de-serialization of corrupted peers.dat throws an exception. // Test that the de-serialization of corrupted peers.dat throws an exception.
CDataStream ssPeers1 = MakeCorruptPeersDat(); CDataStream ssPeers1 = MakeCorruptPeersDat();
bool exceptionThrown = false; bool exceptionThrown = false;
AddrMan addrman1(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 100); AddrMan addrman1(/*asmap=*/std::vector<bool>(), /*deterministic=*/false, /*consistency_check_ratio=*/100);
BOOST_CHECK(addrman1.size() == 0); BOOST_CHECK(addrman1.size() == 0);
try { try {
unsigned char pchMsgTmp[4]; unsigned char pchMsgTmp[4];
@ -1044,7 +1044,7 @@ BOOST_AUTO_TEST_CASE(load_addrman_corrupted)
// Test that ReadFromStream fails if peers.dat is corrupt // Test that ReadFromStream fails if peers.dat is corrupt
CDataStream ssPeers2 = MakeCorruptPeersDat(); CDataStream ssPeers2 = MakeCorruptPeersDat();
AddrMan addrman2(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 100); AddrMan addrman2(/*asmap=*/std::vector<bool>(), /*deterministic=*/false, /*consistency_check_ratio=*/100);
BOOST_CHECK(addrman2.size() == 0); BOOST_CHECK(addrman2.size() == 0);
BOOST_CHECK_THROW(ReadFromStream(addrman2, ssPeers2), std::ios_base::failure); BOOST_CHECK_THROW(ReadFromStream(addrman2, ssPeers2), std::ios_base::failure);
} }

View File

@ -269,7 +269,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test)
CCoinsViewTest base; CCoinsViewTest base;
SimulationTest(&base, false); SimulationTest(&base, false);
CCoinsViewDB db_base{"test", /*nCacheSize*/ 1 << 23, /*fMemory*/ true, /*fWipe*/ false}; CCoinsViewDB db_base{"test", /*nCacheSize=*/1 << 23, /*fMemory=*/true, /*fWipe=*/false};
SimulationTest(&db_base, true); SimulationTest(&db_base, true);
} }

View File

@ -213,13 +213,13 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
banman->ClearBanned(); banman->ClearBanned();
nodes[0] = new CNode{id++, NODE_NETWORK, INVALID_SOCKET, addr[0], /*nKeyedNetGroupIn=*/0, nodes[0] = new CNode{id++, NODE_NETWORK, INVALID_SOCKET, addr[0], /*nKeyedNetGroupIn=*/0,
/*nLocalHostNonceIn */ 0, CAddress(), /*addrNameIn=*/"", /*nLocalHostNonceIn=*/0, CAddress(), /*addrNameIn=*/"",
ConnectionType::INBOUND, /*inbound_onion=*/false}; ConnectionType::INBOUND, /*inbound_onion=*/false};
nodes[0]->SetCommonVersion(PROTOCOL_VERSION); nodes[0]->SetCommonVersion(PROTOCOL_VERSION);
peerLogic->InitializeNode(nodes[0]); peerLogic->InitializeNode(nodes[0]);
nodes[0]->fSuccessfullyConnected = true; nodes[0]->fSuccessfullyConnected = true;
connman->AddTestNode(*nodes[0]); connman->AddTestNode(*nodes[0]);
peerLogic->Misbehaving(nodes[0]->GetId(), DISCOURAGEMENT_THRESHOLD, /* message */ ""); // Should be discouraged peerLogic->Misbehaving(nodes[0]->GetId(), DISCOURAGEMENT_THRESHOLD, /*message=*/""); // Should be discouraged
{ {
LOCK(nodes[0]->cs_sendProcessing); LOCK(nodes[0]->cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(nodes[0])); BOOST_CHECK(peerLogic->SendMessages(nodes[0]));
@ -229,13 +229,13 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
BOOST_CHECK(!banman->IsDiscouraged(other_addr)); // Different address, not discouraged BOOST_CHECK(!banman->IsDiscouraged(other_addr)); // Different address, not discouraged
nodes[1] = new CNode{id++, NODE_NETWORK, INVALID_SOCKET, addr[1], /*nKeyedNetGroupIn=*/1, nodes[1] = new CNode{id++, NODE_NETWORK, INVALID_SOCKET, addr[1], /*nKeyedNetGroupIn=*/1,
/*nLocalHostNonceIn */ 1, CAddress(), /*addrNameIn=*/"", /*nLocalHostNonceIn=*/1, CAddress(), /*addrNameIn=*/"",
ConnectionType::INBOUND, /*inbound_onion=*/false}; ConnectionType::INBOUND, /*inbound_onion=*/false};
nodes[1]->SetCommonVersion(PROTOCOL_VERSION); nodes[1]->SetCommonVersion(PROTOCOL_VERSION);
peerLogic->InitializeNode(nodes[1]); peerLogic->InitializeNode(nodes[1]);
nodes[1]->fSuccessfullyConnected = true; nodes[1]->fSuccessfullyConnected = true;
connman->AddTestNode(*nodes[1]); connman->AddTestNode(*nodes[1]);
peerLogic->Misbehaving(nodes[1]->GetId(), DISCOURAGEMENT_THRESHOLD - 1, /* message */ ""); peerLogic->Misbehaving(nodes[1]->GetId(), DISCOURAGEMENT_THRESHOLD - 1, /*message=*/"");
{ {
LOCK(nodes[1]->cs_sendProcessing); LOCK(nodes[1]->cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(nodes[1])); BOOST_CHECK(peerLogic->SendMessages(nodes[1]));
@ -246,7 +246,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
// [1] is not discouraged/disconnected yet. // [1] is not discouraged/disconnected yet.
BOOST_CHECK(!banman->IsDiscouraged(addr[1])); BOOST_CHECK(!banman->IsDiscouraged(addr[1]));
BOOST_CHECK(!nodes[1]->fDisconnect); BOOST_CHECK(!nodes[1]->fDisconnect);
peerLogic->Misbehaving(nodes[1]->GetId(), 1, /* message */ ""); // [1] reaches discouragement threshold peerLogic->Misbehaving(nodes[1]->GetId(), 1, /*message=*/""); // [1] reaches discouragement threshold
{ {
LOCK(nodes[1]->cs_sendProcessing); LOCK(nodes[1]->cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(nodes[1])); BOOST_CHECK(peerLogic->SendMessages(nodes[1]));
@ -260,13 +260,13 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
// Make sure non-IP peers are discouraged and disconnected properly. // Make sure non-IP peers are discouraged and disconnected properly.
nodes[2] = new CNode{id++, NODE_NETWORK, INVALID_SOCKET, addr[2], /*nKeyedNetGroupIn=*/1, nodes[2] = new CNode{id++, NODE_NETWORK, INVALID_SOCKET, addr[2], /*nKeyedNetGroupIn=*/1,
/*nLocalHostNonceIn */ 1, CAddress(), /*addrNameIn=*/"", /*nLocalHostNonceIn=*/1, CAddress(), /*addrNameIn=*/"",
ConnectionType::OUTBOUND_FULL_RELAY, /*inbound_onion=*/false}; ConnectionType::OUTBOUND_FULL_RELAY, /*inbound_onion=*/false};
nodes[2]->SetCommonVersion(PROTOCOL_VERSION); nodes[2]->SetCommonVersion(PROTOCOL_VERSION);
peerLogic->InitializeNode(nodes[2]); peerLogic->InitializeNode(nodes[2]);
nodes[2]->fSuccessfullyConnected = true; nodes[2]->fSuccessfullyConnected = true;
connman->AddTestNode(*nodes[2]); connman->AddTestNode(*nodes[2]);
peerLogic->Misbehaving(nodes[2]->GetId(), DISCOURAGEMENT_THRESHOLD, /* message */ ""); peerLogic->Misbehaving(nodes[2]->GetId(), DISCOURAGEMENT_THRESHOLD, /*message=*/"");
{ {
LOCK(nodes[2]->cs_sendProcessing); LOCK(nodes[2]->cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(nodes[2])); BOOST_CHECK(peerLogic->SendMessages(nodes[2]));
@ -302,7 +302,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
peerLogic->InitializeNode(&dummyNode); peerLogic->InitializeNode(&dummyNode);
dummyNode.fSuccessfullyConnected = true; dummyNode.fSuccessfullyConnected = true;
peerLogic->Misbehaving(dummyNode.GetId(), DISCOURAGEMENT_THRESHOLD, /* message */ ""); peerLogic->Misbehaving(dummyNode.GetId(), DISCOURAGEMENT_THRESHOLD, /*message=*/"");
{ {
LOCK(dummyNode.cs_sendProcessing); LOCK(dummyNode.cs_sendProcessing);
BOOST_CHECK(peerLogic->SendMessages(&dummyNode)); BOOST_CHECK(peerLogic->SendMessages(&dummyNode));
@ -334,7 +334,7 @@ static void MakeNewKeyWithFastRandomContext(CKey& key)
{ {
std::vector<unsigned char> keydata; std::vector<unsigned char> keydata;
keydata = g_insecure_rand_ctx.randbytes(32); keydata = g_insecure_rand_ctx.randbytes(32);
key.Set(keydata.data(), keydata.data() + keydata.size(), /*fCompressedIn*/ true); key.Set(keydata.data(), keydata.data() + keydata.size(), /*fCompressedIn=*/true);
assert(key.IsValid()); assert(key.IsValid());
} }

View File

@ -29,7 +29,7 @@ FUZZ_TARGET_INIT(data_stream_addr_man, initialize_addrman)
{ {
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
CDataStream data_stream = ConsumeDataStream(fuzzed_data_provider); CDataStream data_stream = ConsumeDataStream(fuzzed_data_provider);
AddrMan addr_man(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 0); AddrMan addr_man(/*asmap=*/std::vector<bool>(), /*deterministic=*/false, /*consistency_check_ratio=*/0);
try { try {
ReadFromStream(addr_man, data_stream); ReadFromStream(addr_man, data_stream);
} catch (const std::exception&) { } catch (const std::exception&) {
@ -113,7 +113,7 @@ class AddrManDeterministic : public AddrMan
{ {
public: public:
explicit AddrManDeterministic(std::vector<bool> asmap, FuzzedDataProvider& fuzzed_data_provider) explicit AddrManDeterministic(std::vector<bool> asmap, FuzzedDataProvider& fuzzed_data_provider)
: AddrMan(std::move(asmap), /* deterministic */ true, /* consistency_check_ratio */ 0) : AddrMan(std::move(asmap), /*deterministic=*/true, /*consistency_check_ratio=*/0)
{ {
WITH_LOCK(m_impl->cs, m_impl->insecure_rand = FastRandomContext{ConsumeUInt256(fuzzed_data_provider)}); WITH_LOCK(m_impl->cs, m_impl->insecure_rand = FastRandomContext{ConsumeUInt256(fuzzed_data_provider)});
} }
@ -286,9 +286,9 @@ FUZZ_TARGET_INIT(addrman, initialize_addrman)
} }
const AddrMan& const_addr_man{addr_man}; const AddrMan& const_addr_man{addr_man};
(void)const_addr_man.GetAddr( (void)const_addr_man.GetAddr(
/* max_addresses */ fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096), /*max_addresses=*/fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096),
/* max_pct */ fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096), /*max_pct=*/fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096),
/* network */ std::nullopt); /*network=*/std::nullopt);
(void)const_addr_man.Select(fuzzed_data_provider.ConsumeBool()); (void)const_addr_man.Select(fuzzed_data_provider.ConsumeBool());
(void)const_addr_man.size(); (void)const_addr_man.size();
CDataStream data_stream(SER_NETWORK, PROTOCOL_VERSION); CDataStream data_stream(SER_NETWORK, PROTOCOL_VERSION);

View File

@ -58,7 +58,7 @@ FUZZ_TARGET_INIT(banman, initialize_banman)
} }
{ {
BanMan ban_man{banlist_file, /* client_interface */ nullptr, /* default_ban_time */ ConsumeBanTimeOffset(fuzzed_data_provider)}; BanMan ban_man{banlist_file, /*client_interface=*/nullptr, /*default_ban_time=*/ConsumeBanTimeOffset(fuzzed_data_provider)};
// The complexity is O(N^2), where N is the input size, because each call // The complexity is O(N^2), where N is the input size, because each call
// might call DumpBanlist (or other methods that are at least linear // might call DumpBanlist (or other methods that are at least linear
// complexity of the input size). // complexity of the input size).
@ -105,7 +105,7 @@ FUZZ_TARGET_INIT(banman, initialize_banman)
SetMockTime(ConsumeTime(fuzzed_data_provider)); SetMockTime(ConsumeTime(fuzzed_data_provider));
banmap_t banmap; banmap_t banmap;
ban_man.GetBanned(banmap); ban_man.GetBanned(banmap);
BanMan ban_man_read{banlist_file, /* client_interface */ nullptr, /* default_ban_time */ 0}; BanMan ban_man_read{banlist_file, /*client_interface=*/nullptr, /*default_ban_time=*/0};
banmap_t banmap_read; banmap_t banmap_read;
ban_man_read.GetBanned(banmap_read); ban_man_read.GetBanned(banmap_read);
assert(banmap == banmap_read); assert(banmap == banmap_read);

View File

@ -25,7 +25,7 @@ FUZZ_TARGET_INIT(connman, initialize_connman)
{ {
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
SetMockTime(ConsumeTime(fuzzed_data_provider)); SetMockTime(ConsumeTime(fuzzed_data_provider));
AddrMan addrman(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 0); AddrMan addrman(/*asmap=*/std::vector<bool>(), /*deterministic=*/false, /*consistency_check_ratio=*/0);
CConnman connman{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>(), addrman, fuzzed_data_provider.ConsumeBool()}; CConnman connman{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>(), addrman, fuzzed_data_provider.ConsumeBool()};
CNetAddr random_netaddr; CNetAddr random_netaddr;
CNode random_node = ConsumeNode(fuzzed_data_provider); CNode random_node = ConsumeNode(fuzzed_data_provider);
@ -69,15 +69,15 @@ FUZZ_TARGET_INIT(connman, initialize_connman)
}, },
[&] { [&] {
(void)connman.GetAddresses( (void)connman.GetAddresses(
/* max_addresses */ fuzzed_data_provider.ConsumeIntegral<size_t>(), /*max_addresses=*/fuzzed_data_provider.ConsumeIntegral<size_t>(),
/* max_pct */ fuzzed_data_provider.ConsumeIntegral<size_t>(), /*max_pct=*/fuzzed_data_provider.ConsumeIntegral<size_t>(),
/* network */ std::nullopt); /*network=*/std::nullopt);
}, },
[&] { [&] {
(void)connman.GetAddresses( (void)connman.GetAddresses(
/* requestor */ random_node, /*requestor=*/random_node,
/* max_addresses */ fuzzed_data_provider.ConsumeIntegral<size_t>(), /*max_addresses=*/fuzzed_data_provider.ConsumeIntegral<size_t>(),
/* max_pct */ fuzzed_data_provider.ConsumeIntegral<size_t>()); /*max_pct=*/fuzzed_data_provider.ConsumeIntegral<size_t>());
}, },
[&] { [&] {
(void)connman.GetDeterministicRandomizer(fuzzed_data_provider.ConsumeIntegral<uint64_t>()); (void)connman.GetDeterministicRandomizer(fuzzed_data_provider.ConsumeIntegral<uint64_t>());

View File

@ -189,7 +189,7 @@ FUZZ_TARGET_DESERIALIZE(blockmerkleroot, {
BlockMerkleRoot(block, &mutated); BlockMerkleRoot(block, &mutated);
}) })
FUZZ_TARGET_DESERIALIZE(addrman_deserialize, { FUZZ_TARGET_DESERIALIZE(addrman_deserialize, {
AddrMan am(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 0); AddrMan am(/*asmap=*/std::vector<bool>(), /*deterministic=*/false, /*consistency_check_ratio=*/0);
DeserializeFromFuzzingInput(buffer, am); DeserializeFromFuzzingInput(buffer, am);
}) })
FUZZ_TARGET_DESERIALIZE(blockheader_deserialize, { FUZZ_TARGET_DESERIALIZE(blockheader_deserialize, {

View File

@ -20,18 +20,18 @@ FUZZ_TARGET(node_eviction)
std::vector<NodeEvictionCandidate> eviction_candidates; std::vector<NodeEvictionCandidate> eviction_candidates;
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) { LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
eviction_candidates.push_back({ eviction_candidates.push_back({
/* id */ fuzzed_data_provider.ConsumeIntegral<NodeId>(), /*id=*/fuzzed_data_provider.ConsumeIntegral<NodeId>(),
/* nTimeConnected */ fuzzed_data_provider.ConsumeIntegral<int64_t>(), /*nTimeConnected=*/fuzzed_data_provider.ConsumeIntegral<int64_t>(),
/* m_min_ping_time */ std::chrono::microseconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()}, /*m_min_ping_time=*/std::chrono::microseconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()},
/* nLastBlockTime */ fuzzed_data_provider.ConsumeIntegral<int64_t>(), /*nLastBlockTime=*/fuzzed_data_provider.ConsumeIntegral<int64_t>(),
/* nLastTXTime */ fuzzed_data_provider.ConsumeIntegral<int64_t>(), /*nLastTXTime=*/fuzzed_data_provider.ConsumeIntegral<int64_t>(),
/* fRelevantServices */ fuzzed_data_provider.ConsumeBool(), /*fRelevantServices=*/fuzzed_data_provider.ConsumeBool(),
/* fRelayTxes */ fuzzed_data_provider.ConsumeBool(), /*fRelayTxes=*/fuzzed_data_provider.ConsumeBool(),
/* fBloomFilter */ fuzzed_data_provider.ConsumeBool(), /*fBloomFilter=*/fuzzed_data_provider.ConsumeBool(),
/* nKeyedNetGroup */ fuzzed_data_provider.ConsumeIntegral<uint64_t>(), /*nKeyedNetGroup=*/fuzzed_data_provider.ConsumeIntegral<uint64_t>(),
/* prefer_evict */ fuzzed_data_provider.ConsumeBool(), /*prefer_evict=*/fuzzed_data_provider.ConsumeBool(),
/* m_is_local */ fuzzed_data_provider.ConsumeBool(), /*m_is_local=*/fuzzed_data_provider.ConsumeBool(),
/* m_network */ fuzzed_data_provider.PickValueInArray(ALL_NETWORKS), /*m_network=*/fuzzed_data_provider.PickValueInArray(ALL_NETWORKS),
}); });
} }
// Make a copy since eviction_candidates may be in some valid but otherwise // Make a copy since eviction_candidates may be in some valid but otherwise

View File

@ -35,7 +35,7 @@ FUZZ_TARGET_INIT(policy_estimator, initialize_policy_estimator)
const CTransaction tx{*mtx}; const CTransaction tx{*mtx};
block_policy_estimator.processTransaction(ConsumeTxMemPoolEntry(fuzzed_data_provider, tx), fuzzed_data_provider.ConsumeBool()); block_policy_estimator.processTransaction(ConsumeTxMemPoolEntry(fuzzed_data_provider, tx), fuzzed_data_provider.ConsumeBool());
if (fuzzed_data_provider.ConsumeBool()) { if (fuzzed_data_provider.ConsumeBool()) {
(void)block_policy_estimator.removeTx(tx.GetHash(), /* inBlock */ fuzzed_data_provider.ConsumeBool()); (void)block_policy_estimator.removeTx(tx.GetHash(), /*inBlock=*/fuzzed_data_provider.ConsumeBool());
} }
}, },
[&] { [&] {
@ -56,7 +56,7 @@ FUZZ_TARGET_INIT(policy_estimator, initialize_policy_estimator)
block_policy_estimator.processBlock(fuzzed_data_provider.ConsumeIntegral<unsigned int>(), ptrs); block_policy_estimator.processBlock(fuzzed_data_provider.ConsumeIntegral<unsigned int>(), ptrs);
}, },
[&] { [&] {
(void)block_policy_estimator.removeTx(ConsumeUInt256(fuzzed_data_provider), /* inBlock */ fuzzed_data_provider.ConsumeBool()); (void)block_policy_estimator.removeTx(ConsumeUInt256(fuzzed_data_provider), /*inBlock=*/fuzzed_data_provider.ConsumeBool());
}, },
[&] { [&] {
block_policy_estimator.FlushUnconfirmed(); block_policy_estimator.FlushUnconfirmed();

View File

@ -83,7 +83,7 @@ void fuzz_target(FuzzBufferType buffer, const std::string& LIMIT_TO_MESSAGE_TYPE
p2p_node.fSuccessfullyConnected = successfully_connected; p2p_node.fSuccessfullyConnected = successfully_connected;
connman.AddTestNode(p2p_node); connman.AddTestNode(p2p_node);
g_setup->m_node.peerman->InitializeNode(&p2p_node); g_setup->m_node.peerman->InitializeNode(&p2p_node);
FillNode(fuzzed_data_provider, p2p_node, /* init_version */ successfully_connected); FillNode(fuzzed_data_provider, p2p_node, /*init_version=*/successfully_connected);
const auto mock_time = ConsumeTime(fuzzed_data_provider); const auto mock_time = ConsumeTime(fuzzed_data_provider);
SetMockTime(mock_time); SetMockTime(mock_time);

View File

@ -50,7 +50,7 @@ FUZZ_TARGET_INIT(process_messages, initialize_process_messages)
p2p_node.fSuccessfullyConnected = successfully_connected; p2p_node.fSuccessfullyConnected = successfully_connected;
p2p_node.fPauseSend = false; p2p_node.fPauseSend = false;
g_setup->m_node.peerman->InitializeNode(&p2p_node); g_setup->m_node.peerman->InitializeNode(&p2p_node);
FillNode(fuzzed_data_provider, p2p_node, /* init_version */ successfully_connected); FillNode(fuzzed_data_provider, p2p_node, /*init_version=*/successfully_connected);
connman.AddTestNode(p2p_node); connman.AddTestNode(p2p_node);
} }

View File

@ -164,7 +164,7 @@ FUZZ_TARGET_INIT(script, initialize_script)
const std::string encoded_dest{EncodeDestination(tx_destination_1)}; const std::string encoded_dest{EncodeDestination(tx_destination_1)};
const UniValue json_dest{DescribeAddress(tx_destination_1)}; const UniValue json_dest{DescribeAddress(tx_destination_1)};
Assert(tx_destination_1 == DecodeDestination(encoded_dest)); Assert(tx_destination_1 == DecodeDestination(encoded_dest));
(void)GetKeyForDestination(/* store */ {}, tx_destination_1); (void)GetKeyForDestination(/*store=*/{}, tx_destination_1);
const CScript dest{GetScriptForDestination(tx_destination_1)}; const CScript dest{GetScriptForDestination(tx_destination_1)};
const bool valid{IsValidDestination(tx_destination_1)}; const bool valid{IsValidDestination(tx_destination_1)};
Assert(dest.empty() != valid); Assert(dest.empty() != valid);

View File

@ -190,7 +190,7 @@ void test_init()
static ECCVerifyHandle handle; static ECCVerifyHandle handle;
} }
FUZZ_TARGET_INIT_HIDDEN(script_assets_test_minimizer, test_init, /* hidden */ true) FUZZ_TARGET_INIT_HIDDEN(script_assets_test_minimizer, test_init, /*hidden=*/true)
{ {
if (buffer.size() < 2 || buffer.back() != '\n' || buffer[buffer.size() - 2] != ',') return; if (buffer.size() < 2 || buffer.back() != '\n' || buffer[buffer.size() - 2] != ',') return;
const std::string str((const char*)buffer.data(), buffer.size() - 2); const std::string str((const char*)buffer.data(), buffer.size() - 2);

View File

@ -103,6 +103,6 @@ FUZZ_TARGET_INIT(transaction, initialize_transaction)
(void)IsWitnessStandard(tx, coins_view_cache); (void)IsWitnessStandard(tx, coins_view_cache);
UniValue u(UniValue::VOBJ); UniValue u(UniValue::VOBJ);
TxToUniv(tx, /* hashBlock */ uint256::ZERO, u); TxToUniv(tx, /*hashBlock=*/uint256::ZERO, u);
TxToUniv(tx, /* hashBlock */ uint256::ONE, u); TxToUniv(tx, /*hashBlock=*/uint256::ONE, u);
} }

View File

@ -85,7 +85,7 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, CCh
{ {
BlockAssembler::Options options; BlockAssembler::Options options;
options.nBlockMaxWeight = fuzzed_data_provider.ConsumeIntegralInRange(0U, MAX_BLOCK_WEIGHT); options.nBlockMaxWeight = fuzzed_data_provider.ConsumeIntegralInRange(0U, MAX_BLOCK_WEIGHT);
options.blockMinFeeRate = CFeeRate{ConsumeMoney(fuzzed_data_provider, /* max */ COIN)}; options.blockMinFeeRate = CFeeRate{ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)};
auto assembler = BlockAssembler{chainstate, *static_cast<CTxMemPool*>(&tx_pool), ::Params(), options}; auto assembler = BlockAssembler{chainstate, *static_cast<CTxMemPool*>(&tx_pool), ::Params(), options};
auto block_template = assembler.CreateNewBlock(CScript{} << OP_TRUE); auto block_template = assembler.CreateNewBlock(CScript{} << OP_TRUE);
Assert(block_template->block.vtx.size() >= 1); Assert(block_template->block.vtx.size() >= 1);
@ -131,7 +131,7 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
// The sum of the values of all spendable outpoints // The sum of the values of all spendable outpoints
constexpr CAmount SUPPLY_TOTAL{COINBASE_MATURITY * 50 * COIN}; constexpr CAmount SUPPLY_TOTAL{COINBASE_MATURITY * 50 * COIN};
CTxMemPool tx_pool_{/* estimator */ nullptr, /* check_ratio */ 1}; CTxMemPool tx_pool_{/*estimator=*/nullptr, /*check_ratio=*/1};
MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(&tx_pool_); MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(&tx_pool_);
// Helper to query an amount // Helper to query an amount
@ -267,10 +267,10 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
// Outpoints that no longer count toward the total supply // Outpoints that no longer count toward the total supply
std::set<COutPoint> consumed_supply; std::set<COutPoint> consumed_supply;
for (const auto& removed_tx : removed) { for (const auto& removed_tx : removed) {
insert_tx(/* created_by_tx */ {consumed_erased}, /* consumed_by_tx */ {outpoints_supply}, /* tx */ *removed_tx); insert_tx(/*created_by_tx=*/{consumed_erased}, /*consumed_by_tx=*/{outpoints_supply}, /*tx=*/*removed_tx);
} }
for (const auto& added_tx : added) { for (const auto& added_tx : added) {
insert_tx(/* created_by_tx */ {outpoints_supply, outpoints_rbf}, /* consumed_by_tx */ {consumed_supply}, /* tx */ *added_tx); insert_tx(/*created_by_tx=*/{outpoints_supply, outpoints_rbf}, /*consumed_by_tx=*/{consumed_supply}, /*tx=*/*added_tx);
} }
for (const auto& p : consumed_erased) { for (const auto& p : consumed_erased) {
Assert(outpoints_supply.erase(p) == 1); Assert(outpoints_supply.erase(p) == 1);
@ -303,7 +303,7 @@ FUZZ_TARGET_INIT(tx_pool, initialize_tx_pool)
txids.push_back(ConsumeUInt256(fuzzed_data_provider)); txids.push_back(ConsumeUInt256(fuzzed_data_provider));
} }
CTxMemPool tx_pool_{/* estimator */ nullptr, /* check_ratio */ 1}; CTxMemPool tx_pool_{/*estimator=*/nullptr, /*check_ratio=*/1};
MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(&tx_pool_); MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(&tx_pool_);
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 300) LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 300)

View File

@ -49,7 +49,7 @@ FUZZ_TARGET_INIT(utxo_snapshot, initialize_chain)
} catch (const std::ios_base::failure&) { } catch (const std::ios_base::failure&) {
return false; return false;
} }
return chainman.ActivateSnapshot(infile, metadata, /* in_memory */ true); return chainman.ActivateSnapshot(infile, metadata, /*in_memory=*/true);
}}; }};
if (fuzzed_data_provider.ConsumeBool()) { if (fuzzed_data_provider.ConsumeBool()) {

View File

@ -602,7 +602,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
// //
// [tx1] // [tx1]
// //
CTransactionRef tx1 = make_tx(/* output_values */ {10 * COIN}); CTransactionRef tx1 = make_tx(/*output_values=*/{10 * COIN});
pool.addUnchecked(entry.Fee(10000LL).FromTx(tx1)); pool.addUnchecked(entry.Fee(10000LL).FromTx(tx1));
// Ancestors / descendants should be 1 / 1 (itself / itself) // Ancestors / descendants should be 1 / 1 (itself / itself)
@ -614,7 +614,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
// //
// [tx1].0 <- [tx2] // [tx1].0 <- [tx2]
// //
CTransactionRef tx2 = make_tx(/* output_values */ {495 * CENT, 5 * COIN}, /* inputs */ {tx1}); CTransactionRef tx2 = make_tx(/*output_values=*/{495 * CENT, 5 * COIN}, /*inputs=*/{tx1});
pool.addUnchecked(entry.Fee(10000LL).FromTx(tx2)); pool.addUnchecked(entry.Fee(10000LL).FromTx(tx2));
// Ancestors / descendants should be: // Ancestors / descendants should be:
@ -633,7 +633,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
// //
// [tx1].0 <- [tx2].0 <- [tx3] // [tx1].0 <- [tx2].0 <- [tx3]
// //
CTransactionRef tx3 = make_tx(/* output_values */ {290 * CENT, 200 * CENT}, /* inputs */ {tx2}); CTransactionRef tx3 = make_tx(/*output_values=*/{290 * CENT, 200 * CENT}, /*inputs=*/{tx2});
pool.addUnchecked(entry.Fee(10000LL).FromTx(tx3)); pool.addUnchecked(entry.Fee(10000LL).FromTx(tx3));
// Ancestors / descendants should be: // Ancestors / descendants should be:
@ -658,7 +658,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
// | // |
// \---1 <- [tx4] // \---1 <- [tx4]
// //
CTransactionRef tx4 = make_tx(/* output_values */ {290 * CENT, 250 * CENT}, /* inputs */ {tx2}, /* input_indices */ {1}); CTransactionRef tx4 = make_tx(/*output_values=*/{290 * CENT, 250 * CENT}, /*inputs=*/{tx2}, /*input_indices=*/{1});
pool.addUnchecked(entry.Fee(10000LL).FromTx(tx4)); pool.addUnchecked(entry.Fee(10000LL).FromTx(tx4));
// Ancestors / descendants should be: // Ancestors / descendants should be:
@ -694,14 +694,14 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
CAmount v = 5 * COIN; CAmount v = 5 * COIN;
for (uint64_t i = 0; i < 5; i++) { for (uint64_t i = 0; i < 5; i++) {
CTransactionRef& tyi = *ty[i]; CTransactionRef& tyi = *ty[i];
tyi = make_tx(/* output_values */ {v}, /* inputs */ i > 0 ? std::vector<CTransactionRef>{*ty[i - 1]} : std::vector<CTransactionRef>{}); tyi = make_tx(/*output_values=*/{v}, /*inputs=*/i > 0 ? std::vector<CTransactionRef>{*ty[i - 1]} : std::vector<CTransactionRef>{});
v -= 50 * CENT; v -= 50 * CENT;
pool.addUnchecked(entry.Fee(10000LL).FromTx(tyi)); pool.addUnchecked(entry.Fee(10000LL).FromTx(tyi));
pool.GetTransactionAncestry(tyi->GetHash(), ancestors, descendants); pool.GetTransactionAncestry(tyi->GetHash(), ancestors, descendants);
BOOST_CHECK_EQUAL(ancestors, i+1); BOOST_CHECK_EQUAL(ancestors, i+1);
BOOST_CHECK_EQUAL(descendants, i+1); BOOST_CHECK_EQUAL(descendants, i+1);
} }
CTransactionRef ty6 = make_tx(/* output_values */ {5 * COIN}, /* inputs */ {tx3, ty5}); CTransactionRef ty6 = make_tx(/*output_values=*/{5 * COIN}, /*inputs=*/{tx3, ty5});
pool.addUnchecked(entry.Fee(10000LL).FromTx(ty6)); pool.addUnchecked(entry.Fee(10000LL).FromTx(ty6));
// Ancestors / descendants should be: // Ancestors / descendants should be:
@ -755,10 +755,10 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
// \---1 <- [tc].0 --<--/ // \---1 <- [tc].0 --<--/
// //
CTransactionRef ta, tb, tc, td; CTransactionRef ta, tb, tc, td;
ta = make_tx(/* output_values */ {10 * COIN}); ta = make_tx(/*output_values=*/{10 * COIN});
tb = make_tx(/* output_values */ {5 * COIN, 3 * COIN}, /* inputs */ {ta}); tb = make_tx(/*output_values=*/{5 * COIN, 3 * COIN}, /*inputs=*/ {ta});
tc = make_tx(/* output_values */ {2 * COIN}, /* inputs */ {tb}, /* input_indices */ {1}); tc = make_tx(/*output_values=*/{2 * COIN}, /*inputs=*/{tb}, /*input_indices=*/{1});
td = make_tx(/* output_values */ {6 * COIN}, /* inputs */ {tb, tc}, /* input_indices */ {0, 0}); td = make_tx(/*output_values=*/{6 * COIN}, /*inputs=*/{tb, tc}, /*input_indices=*/{0, 0});
pool.clear(); pool.clear();
pool.addUnchecked(entry.Fee(10000LL).FromTx(ta)); pool.addUnchecked(entry.Fee(10000LL).FromTx(ta));
pool.addUnchecked(entry.Fee(10000LL).FromTx(tb)); pool.addUnchecked(entry.Fee(10000LL).FromTx(tb));

View File

@ -72,8 +72,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = false; c.m_is_local = false;
c.m_network = NET_IPV4; c.m_network = NET_IPV4;
}, },
/* protected_peer_ids */ {0, 1, 2, 3, 4, 5}, /*protected_peer_ids=*/{0, 1, 2, 3, 4, 5},
/* unprotected_peer_ids */ {6, 7, 8, 9, 10, 11}, /*unprotected_peer_ids=*/{6, 7, 8, 9, 10, 11},
random_context)); random_context));
// Verify in the opposite direction. // Verify in the opposite direction.
@ -83,8 +83,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = false; c.m_is_local = false;
c.m_network = NET_IPV6; c.m_network = NET_IPV6;
}, },
/* protected_peer_ids */ {6, 7, 8, 9, 10, 11}, /*protected_peer_ids=*/{6, 7, 8, 9, 10, 11},
/* unprotected_peer_ids */ {0, 1, 2, 3, 4, 5}, /*unprotected_peer_ids=*/{0, 1, 2, 3, 4, 5},
random_context)); random_context));
// Test protection of onion, localhost, and I2P peers... // Test protection of onion, localhost, and I2P peers...
@ -96,8 +96,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = false; c.m_is_local = false;
c.m_network = (c.id == 3 || c.id == 8 || c.id == 9) ? NET_ONION : NET_IPV4; c.m_network = (c.id == 3 || c.id == 8 || c.id == 9) ? NET_ONION : NET_IPV4;
}, },
/* protected_peer_ids */ {3, 8, 9}, /*protected_peer_ids=*/{3, 8, 9},
/* unprotected_peer_ids */ {}, /*unprotected_peer_ids=*/{},
random_context)); random_context));
// Expect 1/4 onion peers and 1/4 of the other peers to be protected, // Expect 1/4 onion peers and 1/4 of the other peers to be protected,
@ -108,8 +108,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = false; c.m_is_local = false;
c.m_network = (c.id == 3 || c.id > 7) ? NET_ONION : NET_IPV6; c.m_network = (c.id == 3 || c.id > 7) ? NET_ONION : NET_IPV6;
}, },
/* protected_peer_ids */ {0, 1, 2, 3, 8, 9}, /*protected_peer_ids=*/{0, 1, 2, 3, 8, 9},
/* unprotected_peer_ids */ {4, 5, 6, 7, 10, 11}, /*unprotected_peer_ids=*/{4, 5, 6, 7, 10, 11},
random_context)); random_context));
// Expect 1/4 localhost peers to be protected from eviction, // Expect 1/4 localhost peers to be protected from eviction,
@ -119,8 +119,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = (c.id == 1 || c.id == 9 || c.id == 11); c.m_is_local = (c.id == 1 || c.id == 9 || c.id == 11);
c.m_network = NET_IPV4; c.m_network = NET_IPV4;
}, },
/* protected_peer_ids */ {1, 9, 11}, /*protected_peer_ids=*/{1, 9, 11},
/* unprotected_peer_ids */ {}, /*unprotected_peer_ids=*/{},
random_context)); random_context));
// Expect 1/4 localhost peers and 1/4 of the other peers to be protected, // Expect 1/4 localhost peers and 1/4 of the other peers to be protected,
@ -131,8 +131,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = (c.id > 6); c.m_is_local = (c.id > 6);
c.m_network = NET_IPV6; c.m_network = NET_IPV6;
}, },
/* protected_peer_ids */ {0, 1, 2, 7, 8, 9}, /*protected_peer_ids=*/{0, 1, 2, 7, 8, 9},
/* unprotected_peer_ids */ {3, 4, 5, 6, 10, 11}, /*unprotected_peer_ids=*/{3, 4, 5, 6, 10, 11},
random_context)); random_context));
// Expect 1/4 I2P peers to be protected from eviction, // Expect 1/4 I2P peers to be protected from eviction,
@ -142,8 +142,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = false; c.m_is_local = false;
c.m_network = (c.id == 2 || c.id == 7 || c.id == 10) ? NET_I2P : NET_IPV4; c.m_network = (c.id == 2 || c.id == 7 || c.id == 10) ? NET_I2P : NET_IPV4;
}, },
/* protected_peer_ids */ {2, 7, 10}, /*protected_peer_ids=*/{2, 7, 10},
/* unprotected_peer_ids */ {}, /*unprotected_peer_ids=*/{},
random_context)); random_context));
// Expect 1/4 I2P peers and 1/4 of the other peers to be protected, // Expect 1/4 I2P peers and 1/4 of the other peers to be protected,
@ -154,8 +154,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = false; c.m_is_local = false;
c.m_network = (c.id == 4 || c.id > 8) ? NET_I2P : NET_IPV6; c.m_network = (c.id == 4 || c.id > 8) ? NET_I2P : NET_IPV6;
}, },
/* protected_peer_ids */ {0, 1, 2, 4, 9, 10}, /*protected_peer_ids=*/{0, 1, 2, 4, 9, 10},
/* unprotected_peer_ids */ {3, 5, 6, 7, 8, 11}, /*unprotected_peer_ids=*/{3, 5, 6, 7, 8, 11},
random_context)); random_context));
// Tests with 2 networks... // Tests with 2 networks...
@ -169,8 +169,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = (c.id == 4); c.m_is_local = (c.id == 4);
c.m_network = (c.id == 3) ? NET_ONION : NET_IPV4; c.m_network = (c.id == 3) ? NET_ONION : NET_IPV4;
}, },
/* protected_peer_ids */ {0, 4}, /*protected_peer_ids=*/{0, 4},
/* unprotected_peer_ids */ {1, 2}, /*unprotected_peer_ids=*/{1, 2},
random_context)); random_context));
// Combined test: expect having 1 localhost and 1 onion peer out of 7 to // Combined test: expect having 1 localhost and 1 onion peer out of 7 to
@ -182,8 +182,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = (c.id == 6); c.m_is_local = (c.id == 6);
c.m_network = (c.id == 5) ? NET_ONION : NET_IPV4; c.m_network = (c.id == 5) ? NET_ONION : NET_IPV4;
}, },
/* protected_peer_ids */ {0, 1, 6}, /*protected_peer_ids=*/{0, 1, 6},
/* unprotected_peer_ids */ {2, 3, 4, 5}, /*unprotected_peer_ids=*/{2, 3, 4, 5},
random_context)); random_context));
// Combined test: expect having 1 localhost and 1 onion peer out of 8 to // Combined test: expect having 1 localhost and 1 onion peer out of 8 to
@ -195,8 +195,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = (c.id == 6); c.m_is_local = (c.id == 6);
c.m_network = (c.id == 5) ? NET_ONION : NET_IPV4; c.m_network = (c.id == 5) ? NET_ONION : NET_IPV4;
}, },
/* protected_peer_ids */ {0, 1, 5, 6}, /*protected_peer_ids=*/{0, 1, 5, 6},
/* unprotected_peer_ids */ {2, 3, 4, 7}, /*unprotected_peer_ids=*/{2, 3, 4, 7},
random_context)); random_context));
// Combined test: expect having 3 localhost and 3 onion peers out of 12 to // Combined test: expect having 3 localhost and 3 onion peers out of 12 to
@ -208,8 +208,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = (c.id == 6 || c.id == 9 || c.id == 11); c.m_is_local = (c.id == 6 || c.id == 9 || c.id == 11);
c.m_network = (c.id == 7 || c.id == 8 || c.id == 10) ? NET_ONION : NET_IPV6; c.m_network = (c.id == 7 || c.id == 8 || c.id == 10) ? NET_ONION : NET_IPV6;
}, },
/* protected_peer_ids */ {0, 1, 2, 6, 7, 9}, /*protected_peer_ids=*/{0, 1, 2, 6, 7, 9},
/* unprotected_peer_ids */ {3, 4, 5, 8, 10, 11}, /*unprotected_peer_ids=*/{3, 4, 5, 8, 10, 11},
random_context)); random_context));
// Combined test: expect having 4 localhost and 1 onion peer out of 12 to // Combined test: expect having 4 localhost and 1 onion peer out of 12 to
@ -220,8 +220,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = (c.id > 4 && c.id < 9); c.m_is_local = (c.id > 4 && c.id < 9);
c.m_network = (c.id == 10) ? NET_ONION : NET_IPV4; c.m_network = (c.id == 10) ? NET_ONION : NET_IPV4;
}, },
/* protected_peer_ids */ {0, 1, 2, 5, 6, 10}, /*protected_peer_ids=*/{0, 1, 2, 5, 6, 10},
/* unprotected_peer_ids */ {3, 4, 7, 8, 9, 11}, /*unprotected_peer_ids=*/{3, 4, 7, 8, 9, 11},
random_context)); random_context));
// Combined test: expect having 4 localhost and 2 onion peers out of 16 to // Combined test: expect having 4 localhost and 2 onion peers out of 16 to
@ -232,8 +232,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = (c.id == 6 || c.id == 9 || c.id == 11 || c.id == 12); c.m_is_local = (c.id == 6 || c.id == 9 || c.id == 11 || c.id == 12);
c.m_network = (c.id == 8 || c.id == 10) ? NET_ONION : NET_IPV6; c.m_network = (c.id == 8 || c.id == 10) ? NET_ONION : NET_IPV6;
}, },
/* protected_peer_ids */ {0, 1, 2, 3, 6, 8, 9, 10}, /*protected_peer_ids=*/{0, 1, 2, 3, 6, 8, 9, 10},
/* unprotected_peer_ids */ {4, 5, 7, 11, 12, 13, 14, 15}, /*unprotected_peer_ids=*/{4, 5, 7, 11, 12, 13, 14, 15},
random_context)); random_context));
// Combined test: expect having 5 localhost and 1 onion peer out of 16 to // Combined test: expect having 5 localhost and 1 onion peer out of 16 to
@ -245,8 +245,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = (c.id > 10); c.m_is_local = (c.id > 10);
c.m_network = (c.id == 10) ? NET_ONION : NET_IPV4; c.m_network = (c.id == 10) ? NET_ONION : NET_IPV4;
}, },
/* protected_peer_ids */ {0, 1, 2, 3, 10, 11, 12, 13}, /*protected_peer_ids=*/{0, 1, 2, 3, 10, 11, 12, 13},
/* unprotected_peer_ids */ {4, 5, 6, 7, 8, 9, 14, 15}, /*unprotected_peer_ids=*/{4, 5, 6, 7, 8, 9, 14, 15},
random_context)); random_context));
// Combined test: expect having 1 localhost and 4 onion peers out of 16 to // Combined test: expect having 1 localhost and 4 onion peers out of 16 to
@ -258,8 +258,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_is_local = (c.id == 15); c.m_is_local = (c.id == 15);
c.m_network = (c.id > 6 && c.id < 11) ? NET_ONION : NET_IPV6; c.m_network = (c.id > 6 && c.id < 11) ? NET_ONION : NET_IPV6;
}, },
/* protected_peer_ids */ {0, 1, 2, 3, 7, 8, 9, 15}, /*protected_peer_ids=*/{0, 1, 2, 3, 7, 8, 9, 15},
/* unprotected_peer_ids */ {5, 6, 10, 11, 12, 13, 14}, /*unprotected_peer_ids=*/{5, 6, 10, 11, 12, 13, 14},
random_context)); random_context));
// Combined test: expect having 2 onion and 4 I2P out of 12 peers to protect // Combined test: expect having 2 onion and 4 I2P out of 12 peers to protect
@ -277,8 +277,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_network = NET_IPV4; c.m_network = NET_IPV4;
} }
}, },
/* protected_peer_ids */ {0, 1, 2, 6, 8, 10}, /*protected_peer_ids=*/{0, 1, 2, 6, 8, 10},
/* unprotected_peer_ids */ {3, 4, 5, 7, 9, 11}, /*unprotected_peer_ids=*/{3, 4, 5, 7, 9, 11},
random_context)); random_context));
// Tests with 3 networks... // Tests with 3 networks...
@ -298,8 +298,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_network = NET_IPV6; c.m_network = NET_IPV6;
} }
}, },
/* protected_peer_ids */ {0, 4}, /*protected_peer_ids=*/{0, 4},
/* unprotected_peer_ids */ {1, 2}, /*unprotected_peer_ids=*/{1, 2},
random_context)); random_context));
// Combined test: expect having 1 localhost, 1 I2P and 1 onion peer out of 7 // Combined test: expect having 1 localhost, 1 I2P and 1 onion peer out of 7
@ -317,8 +317,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_network = NET_IPV6; c.m_network = NET_IPV6;
} }
}, },
/* protected_peer_ids */ {0, 1, 6}, /*protected_peer_ids=*/{0, 1, 6},
/* unprotected_peer_ids */ {2, 3, 4, 5}, /*unprotected_peer_ids=*/{2, 3, 4, 5},
random_context)); random_context));
// Combined test: expect having 1 localhost, 1 I2P and 1 onion peer out of 8 // Combined test: expect having 1 localhost, 1 I2P and 1 onion peer out of 8
@ -336,8 +336,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_network = NET_IPV6; c.m_network = NET_IPV6;
} }
}, },
/* protected_peer_ids */ {0, 1, 5, 6}, /*protected_peer_ids=*/{0, 1, 5, 6},
/* unprotected_peer_ids */ {2, 3, 4, 7}, /*unprotected_peer_ids=*/{2, 3, 4, 7},
random_context)); random_context));
// Combined test: expect having 4 localhost, 2 I2P, and 2 onion peers out of // Combined test: expect having 4 localhost, 2 I2P, and 2 onion peers out of
@ -355,8 +355,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_network = NET_IPV4; c.m_network = NET_IPV4;
} }
}, },
/* protected_peer_ids */ {0, 1, 2, 3, 6, 7, 9, 11}, /*protected_peer_ids=*/{0, 1, 2, 3, 6, 7, 9, 11},
/* unprotected_peer_ids */ {4, 5, 8, 10, 12, 13, 14, 15}, /*unprotected_peer_ids=*/{4, 5, 8, 10, 12, 13, 14, 15},
random_context)); random_context));
// Combined test: expect having 1 localhost, 8 I2P and 1 onion peer out of // Combined test: expect having 1 localhost, 8 I2P and 1 onion peer out of
@ -374,8 +374,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_network = NET_IPV6; c.m_network = NET_IPV6;
} }
}, },
/* protected_peer_ids */ {0, 1, 2, 3, 4, 5, 12, 15, 16, 17, 18, 23}, /*protected_peer_ids=*/{0, 1, 2, 3, 4, 5, 12, 15, 16, 17, 18, 23},
/* unprotected_peer_ids */ {6, 7, 8, 9, 10, 11, 13, 14, 19, 20, 21, 22}, /*unprotected_peer_ids=*/{6, 7, 8, 9, 10, 11, 13, 14, 19, 20, 21, 22},
random_context)); random_context));
// Combined test: expect having 1 localhost, 3 I2P and 6 onion peers out of // Combined test: expect having 1 localhost, 3 I2P and 6 onion peers out of
@ -393,8 +393,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_network = NET_IPV4; c.m_network = NET_IPV4;
} }
}, },
/* protected_peer_ids */ {0, 1, 2, 3, 4, 5, 12, 14, 15, 17, 18, 19}, /*protected_peer_ids=*/{0, 1, 2, 3, 4, 5, 12, 14, 15, 17, 18, 19},
/* unprotected_peer_ids */ {6, 7, 8, 9, 10, 11, 13, 16, 20, 21, 22, 23}, /*unprotected_peer_ids=*/{6, 7, 8, 9, 10, 11, 13, 16, 20, 21, 22, 23},
random_context)); random_context));
// Combined test: expect having 1 localhost, 7 I2P and 4 onion peers out of // Combined test: expect having 1 localhost, 7 I2P and 4 onion peers out of
@ -412,8 +412,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_network = NET_IPV6; c.m_network = NET_IPV6;
} }
}, },
/* protected_peer_ids */ {0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 17, 18}, /*protected_peer_ids=*/{0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 17, 18},
/* unprotected_peer_ids */ {6, 7, 8, 9, 10, 11, 16, 19, 20, 21, 22, 23}, /*unprotected_peer_ids=*/{6, 7, 8, 9, 10, 11, 16, 19, 20, 21, 22, 23},
random_context)); random_context));
// Combined test: expect having 8 localhost, 4 I2P, and 3 onion peers out of // Combined test: expect having 8 localhost, 4 I2P, and 3 onion peers out of
@ -431,8 +431,8 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
c.m_network = NET_IPV4; c.m_network = NET_IPV4;
} }
}, },
/* protected_peer_ids */ {0, 1, 2, 3, 4, 5, 7, 8, 11, 12, 16, 17}, /*protected_peer_ids=*/{0, 1, 2, 3, 4, 5, 7, 8, 11, 12, 16, 17},
/* unprotected_peer_ids */ {6, 9, 10, 13, 14, 15, 18, 19, 20, 21, 22, 23}, /*unprotected_peer_ids=*/{6, 9, 10, 13, 14, 15, 18, 19, 20, 21, 22, 23},
random_context)); random_context));
} }

View File

@ -607,7 +607,7 @@ BOOST_AUTO_TEST_CASE(ipv4_peer_with_ipv6_addrMe_test)
in_addr ipv4AddrPeer; in_addr ipv4AddrPeer;
ipv4AddrPeer.s_addr = 0xa0b0c001; ipv4AddrPeer.s_addr = 0xa0b0c001;
CAddress addr = CAddress(CService(ipv4AddrPeer, 7777), NODE_NETWORK); CAddress addr = CAddress(CService(ipv4AddrPeer, 7777), NODE_NETWORK);
std::unique_ptr<CNode> pnode = std::make_unique<CNode>(0, NODE_NETWORK, INVALID_SOCKET, addr, /* nKeyedNetGroupIn */ 0, /* nLocalHostNonceIn */ 0, CAddress{}, /* pszDest */ std::string{}, ConnectionType::OUTBOUND_FULL_RELAY, /* inbound_onion */ false); std::unique_ptr<CNode> pnode = std::make_unique<CNode>(0, NODE_NETWORK, INVALID_SOCKET, addr, /*nKeyedNetGroupIn=*/0, /*nLocalHostNonceIn=*/0, CAddress{}, /*pszDest=*/std::string{}, ConnectionType::OUTBOUND_FULL_RELAY, /*inbound_onion=*/false);
pnode->fSuccessfullyConnected.store(true); pnode->fSuccessfullyConnected.store(true);
// the peer claims to be reaching us via IPv6 // the peer claims to be reaching us via IPv6

View File

@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(manythreads)
std::mutex counterMutex[10]; std::mutex counterMutex[10];
int counter[10] = { 0 }; int counter[10] = { 0 };
FastRandomContext rng{/* fDeterministic */ true}; FastRandomContext rng{/*fDeterministic=*/true};
auto zeroToNine = [](FastRandomContext& rc) -> int { return rc.randrange(10); }; // [0, 9] auto zeroToNine = [](FastRandomContext& rc) -> int { return rc.randrange(10); }; // [0, 9]
auto randomMsec = [](FastRandomContext& rc) -> int { return -11 + (int)rc.randrange(1012); }; // [-11, 1000] auto randomMsec = [](FastRandomContext& rc) -> int { return -11 + (int)rc.randrange(1012); }; // [-11, 1000]
auto randomDelta = [](FastRandomContext& rc) -> int { return -1000 + (int)rc.randrange(2001); }; // [-1000, 1000] auto randomDelta = [](FastRandomContext& rc) -> int { return -1000 + (int)rc.randrange(2001); }; // [-1000, 1000]

View File

@ -249,26 +249,26 @@ BOOST_AUTO_TEST_CASE(tx_valid)
BOOST_ERROR("Bad test flags: " << strTest); BOOST_ERROR("Bad test flags: " << strTest);
} }
BOOST_CHECK_MESSAGE(CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, ~verify_flags, txdata, strTest, /* expect_valid */ true), BOOST_CHECK_MESSAGE(CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, ~verify_flags, txdata, strTest, /*expect_valid=*/true),
"Tx unexpectedly failed: " << strTest); "Tx unexpectedly failed: " << strTest);
// Backwards compatibility of script verification flags: Removing any flag(s) should not invalidate a valid transaction // Backwards compatibility of script verification flags: Removing any flag(s) should not invalidate a valid transaction
for (const auto& [name, flag] : mapFlagNames) { for (const auto& [name, flag] : mapFlagNames) {
// Removing individual flags // Removing individual flags
unsigned int flags = TrimFlags(~(verify_flags | flag)); unsigned int flags = TrimFlags(~(verify_flags | flag));
if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags, txdata, strTest, /* expect_valid */ true)) { if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags, txdata, strTest, /*expect_valid=*/true)) {
BOOST_ERROR("Tx unexpectedly failed with flag " << name << " unset: " << strTest); BOOST_ERROR("Tx unexpectedly failed with flag " << name << " unset: " << strTest);
} }
// Removing random combinations of flags // Removing random combinations of flags
flags = TrimFlags(~(verify_flags | (unsigned int)InsecureRandBits(mapFlagNames.size()))); flags = TrimFlags(~(verify_flags | (unsigned int)InsecureRandBits(mapFlagNames.size())));
if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags, txdata, strTest, /* expect_valid */ true)) { if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags, txdata, strTest, /*expect_valid=*/true)) {
BOOST_ERROR("Tx unexpectedly failed with random flags " << ToString(flags) << ": " << strTest); BOOST_ERROR("Tx unexpectedly failed with random flags " << ToString(flags) << ": " << strTest);
} }
} }
// Check that flags are maximal: transaction should fail if any unset flags are set. // Check that flags are maximal: transaction should fail if any unset flags are set.
for (auto flags_excluding_one : ExcludeIndividualFlags(verify_flags)) { for (auto flags_excluding_one : ExcludeIndividualFlags(verify_flags)) {
if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, ~flags_excluding_one, txdata, strTest, /* expect_valid */ false)) { if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, ~flags_excluding_one, txdata, strTest, /*expect_valid=*/false)) {
BOOST_ERROR("Too many flags unset: " << strTest); BOOST_ERROR("Too many flags unset: " << strTest);
} }
} }
@ -340,26 +340,26 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
} }
// Not using FillFlags() in the main test, in order to detect invalid verifyFlags combination // Not using FillFlags() in the main test, in order to detect invalid verifyFlags combination
BOOST_CHECK_MESSAGE(CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, verify_flags, txdata, strTest, /* expect_valid */ false), BOOST_CHECK_MESSAGE(CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, verify_flags, txdata, strTest, /*expect_valid=*/false),
"Tx unexpectedly passed: " << strTest); "Tx unexpectedly passed: " << strTest);
// Backwards compatibility of script verification flags: Adding any flag(s) should not validate an invalid transaction // Backwards compatibility of script verification flags: Adding any flag(s) should not validate an invalid transaction
for (const auto& [name, flag] : mapFlagNames) { for (const auto& [name, flag] : mapFlagNames) {
unsigned int flags = FillFlags(verify_flags | flag); unsigned int flags = FillFlags(verify_flags | flag);
// Adding individual flags // Adding individual flags
if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags, txdata, strTest, /* expect_valid */ false)) { if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags, txdata, strTest, /*expect_valid=*/false)) {
BOOST_ERROR("Tx unexpectedly passed with flag " << name << " set: " << strTest); BOOST_ERROR("Tx unexpectedly passed with flag " << name << " set: " << strTest);
} }
// Adding random combinations of flags // Adding random combinations of flags
flags = FillFlags(verify_flags | (unsigned int)InsecureRandBits(mapFlagNames.size())); flags = FillFlags(verify_flags | (unsigned int)InsecureRandBits(mapFlagNames.size()));
if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags, txdata, strTest, /* expect_valid */ false)) { if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags, txdata, strTest, /*expect_valid=*/false)) {
BOOST_ERROR("Tx unexpectedly passed with random flags " << name << ": " << strTest); BOOST_ERROR("Tx unexpectedly passed with random flags " << name << ": " << strTest);
} }
} }
// Check that flags are minimal: transaction should succeed if any set flags are unset. // Check that flags are minimal: transaction should succeed if any set flags are unset.
for (auto flags_excluding_one : ExcludeIndividualFlags(verify_flags)) { for (auto flags_excluding_one : ExcludeIndividualFlags(verify_flags)) {
if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags_excluding_one, txdata, strTest, /* expect_valid */ true)) { if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags_excluding_one, txdata, strTest, /*expect_valid=*/true)) {
BOOST_ERROR("Too many flags set: " << strTest); BOOST_ERROR("Too many flags set: " << strTest);
} }
} }

View File

@ -84,10 +84,10 @@ BOOST_FIXTURE_TEST_CASE(package_validation_tests, TestChain100Setup)
CScript child_locking_script = GetScriptForDestination(PKHash(child_key.GetPubKey())); CScript child_locking_script = GetScriptForDestination(PKHash(child_key.GetPubKey()));
auto mtx_child = CreateValidMempoolTransaction(/*input_transaction=*/ tx_parent, /*input_vout=*/0, auto mtx_child = CreateValidMempoolTransaction(/*input_transaction=*/ tx_parent, /*input_vout=*/0,
/*input_height=*/ 101, /*input_signing_key=*/parent_key, /*input_height=*/ 101, /*input_signing_key=*/parent_key,
/*output_destination */ child_locking_script, /*output_destination=*/child_locking_script,
/*output_amount=*/ CAmount(48 * COIN), /*submit=*/false); /*output_amount=*/ CAmount(48 * COIN), /*submit=*/false);
CTransactionRef tx_child = MakeTransactionRef(mtx_child); CTransactionRef tx_child = MakeTransactionRef(mtx_child);
const auto result_parent_child = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, {tx_parent, tx_child}, /* test_accept */ true); const auto result_parent_child = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, {tx_parent, tx_child}, /*test_accept=*/true);
BOOST_CHECK_MESSAGE(result_parent_child.m_state.IsValid(), BOOST_CHECK_MESSAGE(result_parent_child.m_state.IsValid(),
"Package validation unexpectedly failed: " << result_parent_child.m_state.GetRejectReason()); "Package validation unexpectedly failed: " << result_parent_child.m_state.GetRejectReason());
auto it_parent = result_parent_child.m_tx_results.find(tx_parent->GetWitnessHash()); auto it_parent = result_parent_child.m_tx_results.find(tx_parent->GetWitnessHash());
@ -103,7 +103,7 @@ BOOST_FIXTURE_TEST_CASE(package_validation_tests, TestChain100Setup)
// A single, giant transaction submitted through ProcessNewPackage fails on single tx policy. // A single, giant transaction submitted through ProcessNewPackage fails on single tx policy.
CTransactionRef giant_ptx = create_placeholder_tx(999, 999); CTransactionRef giant_ptx = create_placeholder_tx(999, 999);
BOOST_CHECK(GetVirtualTransactionSize(*giant_ptx) > MAX_PACKAGE_SIZE * 1000); BOOST_CHECK(GetVirtualTransactionSize(*giant_ptx) > MAX_PACKAGE_SIZE * 1000);
auto result_single_large = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, {giant_ptx}, /* test_accept */ true); auto result_single_large = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, {giant_ptx}, /*test_accept=*/true);
BOOST_CHECK(result_single_large.m_state.IsInvalid()); BOOST_CHECK(result_single_large.m_state.IsInvalid());
BOOST_CHECK_EQUAL(result_single_large.m_state.GetResult(), PackageValidationResult::PCKG_TX); BOOST_CHECK_EQUAL(result_single_large.m_state.GetResult(), PackageValidationResult::PCKG_TX);
BOOST_CHECK_EQUAL(result_single_large.m_state.GetRejectReason(), "transaction failed"); BOOST_CHECK_EQUAL(result_single_large.m_state.GetRejectReason(), "transaction failed");

View File

@ -47,7 +47,7 @@ CreateAndActivateUTXOSnapshot(NodeContext& node, const fs::path root, F malleati
malleation(auto_infile, metadata); malleation(auto_infile, metadata);
return node.chainman->ActivateSnapshot(auto_infile, metadata, /*in_memory*/ true); return node.chainman->ActivateSnapshot(auto_infile, metadata, /*in_memory=*/true);
} }

View File

@ -46,18 +46,18 @@ std::vector<NodeEvictionCandidate> GetRandomNodeEvictionCandidates(int n_candida
std::vector<NodeEvictionCandidate> candidates; std::vector<NodeEvictionCandidate> candidates;
for (int id = 0; id < n_candidates; ++id) { for (int id = 0; id < n_candidates; ++id) {
candidates.push_back({ candidates.push_back({
/* id */ id, /*id=*/id,
/* nTimeConnected */ static_cast<int64_t>(random_context.randrange(100)), /*nTimeConnected=*/static_cast<int64_t>(random_context.randrange(100)),
/* m_min_ping_time */ std::chrono::microseconds{random_context.randrange(100)}, /*m_min_ping_time=*/std::chrono::microseconds{random_context.randrange(100)},
/* nLastBlockTime */ static_cast<int64_t>(random_context.randrange(100)), /*nLastBlockTime=*/static_cast<int64_t>(random_context.randrange(100)),
/* nLastTXTime */ static_cast<int64_t>(random_context.randrange(100)), /*nLastTXTime=*/static_cast<int64_t>(random_context.randrange(100)),
/* fRelevantServices */ random_context.randbool(), /*fRelevantServices=*/random_context.randbool(),
/* fRelayTxes */ random_context.randbool(), /*fRelayTxes=*/random_context.randbool(),
/* fBloomFilter */ random_context.randbool(), /*fBloomFilter=*/random_context.randbool(),
/* nKeyedNetGroup */ random_context.randrange(100), /*nKeyedNetGroup=*/random_context.randrange(100),
/* prefer_evict */ random_context.randbool(), /*prefer_evict=*/random_context.randbool(),
/* m_is_local */ random_context.randbool(), /*m_is_local=*/random_context.randbool(),
/* m_network */ ALL_NETWORKS[random_context.randrange(ALL_NETWORKS.size())], /*m_network=*/ALL_NETWORKS[random_context.randrange(ALL_NETWORKS.size())],
}); });
} }
return candidates; return candidates;

View File

@ -179,7 +179,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
m_node.chainman->InitializeChainstate(m_node.mempool.get()); m_node.chainman->InitializeChainstate(m_node.mempool.get());
m_node.chainman->ActiveChainstate().InitCoinsDB( m_node.chainman->ActiveChainstate().InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false); /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
assert(!m_node.chainman->ActiveChainstate().CanFlushToDisk()); assert(!m_node.chainman->ActiveChainstate().CanFlushToDisk());
m_node.chainman->ActiveChainstate().InitCoinsCache(1 << 23); m_node.chainman->ActiveChainstate().InitCoinsCache(1 << 23);
assert(m_node.chainman->ActiveChainstate().CanFlushToDisk()); assert(m_node.chainman->ActiveChainstate().CanFlushToDisk());
@ -192,7 +192,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString())); throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString()));
} }
m_node.addrman = std::make_unique<AddrMan>(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 0); m_node.addrman = std::make_unique<AddrMan>(/*asmap=*/std::vector<bool>(), /*deterministic=*/false, /*consistency_check_ratio=*/0);
m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME); m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests. m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests.
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman, m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman,

View File

@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool)); CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool));
c1.InitCoinsDB( c1.InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false); /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23)); WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));
// Add a coin to the in-memory cache, upsize once, then downsize. // Add a coin to the in-memory cache, upsize once, then downsize.

View File

@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
CChainState& c1 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(&mempool)); CChainState& c1 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(&mempool));
chainstates.push_back(&c1); chainstates.push_back(&c1);
c1.InitCoinsDB( c1.InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false); /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23)); WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));
BOOST_CHECK(!manager.IsSnapshotActive()); BOOST_CHECK(!manager.IsSnapshotActive());
@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
BOOST_CHECK_EQUAL(manager.SnapshotBlockhash().value(), snapshot_blockhash); BOOST_CHECK_EQUAL(manager.SnapshotBlockhash().value(), snapshot_blockhash);
c2.InitCoinsDB( c2.InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false); /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
WITH_LOCK(::cs_main, c2.InitCoinsCache(1 << 23)); WITH_LOCK(::cs_main, c2.InitCoinsCache(1 << 23));
// Unlike c1, which doesn't have any blocks. Gets us different tip, height. // Unlike c1, which doesn't have any blocks. Gets us different tip, height.
c2.LoadGenesisBlock(); c2.LoadGenesisBlock();
@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool)); CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool));
chainstates.push_back(&c1); chainstates.push_back(&c1);
c1.InitCoinsDB( c1.InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false); /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
{ {
LOCK(::cs_main); LOCK(::cs_main);
@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
CChainState& c2 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool, GetRandHash())); CChainState& c2 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool, GetRandHash()));
chainstates.push_back(&c2); chainstates.push_back(&c2);
c2.InitCoinsDB( c2.InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false); /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
{ {
LOCK(::cs_main); LOCK(::cs_main);

View File

@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
CTxMemPool mempool; CTxMemPool mempool;
BlockManager blockman{}; BlockManager blockman{};
CChainState chainstate{&mempool, blockman, *Assert(m_node.chainman)}; CChainState chainstate{&mempool, blockman, *Assert(m_node.chainman)};
chainstate.InitCoinsDB(/*cache_size_bytes*/ 1 << 10, /*in_memory*/ true, /*should_wipe*/ false); chainstate.InitCoinsDB(/*cache_size_bytes=*/1 << 10, /*in_memory=*/true, /*should_wipe=*/false);
WITH_LOCK(::cs_main, chainstate.InitCoinsCache(1 << 10)); WITH_LOCK(::cs_main, chainstate.InitCoinsCache(1 << 10));
constexpr bool is_64_bit = sizeof(void*) == 8; constexpr bool is_64_bit = sizeof(void*) == 8;
@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
// Without any coins in the cache, we shouldn't need to flush. // Without any coins in the cache, we shouldn't need to flush.
BOOST_CHECK_EQUAL( BOOST_CHECK_EQUAL(
chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 0), chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes=*/0),
CoinsCacheSizeState::OK); CoinsCacheSizeState::OK);
// If the initial memory allocations of cacheCoins don't match these common // If the initial memory allocations of cacheCoins don't match these common
@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
} }
BOOST_CHECK_EQUAL( BOOST_CHECK_EQUAL(
chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 0), chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes=*/0),
CoinsCacheSizeState::CRITICAL); CoinsCacheSizeState::CRITICAL);
BOOST_TEST_MESSAGE("Exiting cache flush tests early due to unsupported arch"); BOOST_TEST_MESSAGE("Exiting cache flush tests early due to unsupported arch");
@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
print_view_mem_usage(view); print_view_mem_usage(view);
BOOST_CHECK_EQUAL(view.AccessCoin(res).DynamicMemoryUsage(), COIN_SIZE); BOOST_CHECK_EQUAL(view.AccessCoin(res).DynamicMemoryUsage(), COIN_SIZE);
BOOST_CHECK_EQUAL( BOOST_CHECK_EQUAL(
chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 0), chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes=*/0),
CoinsCacheSizeState::OK); CoinsCacheSizeState::OK);
} }
@ -100,26 +100,26 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
for (int i{0}; i < 4; ++i) { for (int i{0}; i < 4; ++i) {
add_coin(view); add_coin(view);
print_view_mem_usage(view); print_view_mem_usage(view);
if (chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 0) == if (chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes=*/0) ==
CoinsCacheSizeState::CRITICAL) { CoinsCacheSizeState::CRITICAL) {
break; break;
} }
} }
BOOST_CHECK_EQUAL( BOOST_CHECK_EQUAL(
chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 0), chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes=*/0),
CoinsCacheSizeState::CRITICAL); CoinsCacheSizeState::CRITICAL);
// Passing non-zero max mempool usage should allow us more headroom. // Passing non-zero max mempool usage should allow us more headroom.
BOOST_CHECK_EQUAL( BOOST_CHECK_EQUAL(
chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 1 << 10), chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes=*/1 << 10),
CoinsCacheSizeState::OK); CoinsCacheSizeState::OK);
for (int i{0}; i < 3; ++i) { for (int i{0}; i < 3; ++i) {
add_coin(view); add_coin(view);
print_view_mem_usage(view); print_view_mem_usage(view);
BOOST_CHECK_EQUAL( BOOST_CHECK_EQUAL(
chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes*/ 1 << 10), chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, /*max_mempool_size_bytes=*/1 << 10),
CoinsCacheSizeState::OK); CoinsCacheSizeState::OK);
} }

View File

@ -133,7 +133,7 @@ inline std::vector<OutputGroup>& KnapsackGroupOutputs(const std::vector<COutput>
/* long_term_feerate= */ CFeeRate(0), /* discard_feerate= */ CFeeRate(0), /* long_term_feerate= */ CFeeRate(0), /* discard_feerate= */ CFeeRate(0),
/* tx_noinputs_size= */ 0, /* avoid_partial= */ false); /* tx_noinputs_size= */ 0, /* avoid_partial= */ false);
static std::vector<OutputGroup> static_groups; static std::vector<OutputGroup> static_groups;
static_groups = GroupOutputs(wallet, coins, coin_selection_params, filter, /* positive_only */false); static_groups = GroupOutputs(wallet, coins, coin_selection_params, filter, /*positive_only=*/false);
return static_groups; return static_groups;
} }
@ -733,7 +733,7 @@ BOOST_AUTO_TEST_CASE(waste_test)
add_coin(1 * COIN, 1, selection, fee, fee); add_coin(1 * COIN, 1, selection, fee, fee);
add_coin(2 * COIN, 2, selection, fee, fee); add_coin(2 * COIN, 2, selection, fee, fee);
const CAmount exact_target{in_amt - fee * 2}; const CAmount exact_target{in_amt - fee * 2};
BOOST_CHECK_EQUAL(0, GetSelectionWaste(selection, /* change_cost */ 0, exact_target)); BOOST_CHECK_EQUAL(0, GetSelectionWaste(selection, /*change_cost=*/0, exact_target));
selection.clear(); selection.clear();
// No Waste when (fee - long_term_fee) == (-cost_of_change), and no excess // No Waste when (fee - long_term_fee) == (-cost_of_change), and no excess